[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/prismarine](https://jsprismarine.dev/api/@jsprismarine/prismarine/index.md) / command/function/load

# command/function/load

## Interfaces

### FunctionContent

Defined in: [packages/prismarine/src/command/function/load.ts:29](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/command/function/load.ts#L29)

The two halves of a content build this module reads.

Narrower than `ServerContent` on purpose: a test states a map of functions
and a tag table and gets the real compile, and nothing here is coupled to
the eighteen other registries a content build carries.

#### Properties

##### functions

> `readonly` **functions**: `ReadonlyMap`\<`string`, [`Definition`](https://jsprismarine.dev/api/@jsprismarine/packs/index.md#definition)\>

Defined in: [packages/prismarine/src/command/function/load.ts:31](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/command/function/load.ts#L31)

The `functions` registry of a loaded pack stack, whose `data` is the file's text.

##### tags?

> `readonly` `optional` **tags?**: `Pick`\<[`ContentTags`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/tags/index.md#contenttags), `"tags"` \| `"members"` \| `"has"`\>

Defined in: [packages/prismarine/src/command/function/load.ts:33](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/command/function/load.ts#L33)

The merged tags, read for the `function` registry alone.

***

### ServerFunctions

Defined in: [packages/prismarine/src/command/function/load.ts:37](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/command/function/load.ts#L37)

What a pack stack's function half amounts to.

#### Properties

##### diagnostics

> `readonly` **diagnostics**: readonly [`Diagnostic`](https://jsprismarine.dev/api/@jsprismarine/mcfunction/index.md#diagnostic)[]

Defined in: [packages/prismarine/src/command/function/load.ts:45](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/command/function/load.ts#L45)

Everything compiling reported. A file that did not compile is left out.

##### functions

> `readonly` **functions**: [`FunctionRegistry`](https://jsprismarine.dev/api/@jsprismarine/mcfunction/classes/FunctionRegistry.md)

Defined in: [packages/prismarine/src/command/function/load.ts:39](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/command/function/load.ts#L39)

Every function that compiled, keyed by namespaced id.

##### tagIds

> `readonly` **tagIds**: readonly `string`[]

Defined in: [packages/prismarine/src/command/function/load.ts:43](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/command/function/load.ts#L43)

Every tag id the stack declares, for a caller that wants to list them.

##### tags

> `readonly` **tags**: [`FunctionTagLookup`](https://jsprismarine.dev/api/@jsprismarine/mcfunction/index.md#functiontaglookup)

Defined in: [packages/prismarine/src/command/function/load.ts:41](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/command/function/load.ts#L41)

The function tags, which `/function #tag` and the tick tag resolve through.

## Variables

### FUNCTION\_TAG\_REGISTRY

> `const` **FUNCTION\_TAG\_REGISTRY**: `"function"` = `'function'`

Defined in: [packages/prismarine/src/command/function/load.ts:20](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/command/function/load.ts#L20)

The registry a datapack's function tags live in, as `routeDatapackPath` names it.

## Functions

### functionContentOf()

> **functionContentOf**(`content`): [`FunctionContent`](#functioncontent)

Defined in: [packages/prismarine/src/command/function/load.ts:100](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/command/function/load.ts#L100)

The function half of a content build.

The one place the narrow [FunctionContent](#functioncontent) is joined back to the
whole, so everything else in this directory stays free of the eighteen
registries it does not read.

#### Parameters

##### content

[`ServerContent`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/ServerContent/index.md#servercontent)

#### Returns

[`FunctionContent`](#functioncontent)

The two registries the function loader reads.

***

### loadServerFunctions()

> **loadServerFunctions**(`content`): [`ServerFunctions`](#serverfunctions)

Defined in: [packages/prismarine/src/command/function/load.ts:69](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/command/function/load.ts#L69)

Compiles every function the stack registered.

A stack holding no datapack compiles to an empty registry rather than a
refusal: `/function` then reports that the function it was given does not
exist, which is what Java reports for the same input.

#### Parameters

##### content

[`FunctionContent`](#functioncontent)

The function half of a content build.

#### Returns

[`ServerFunctions`](#serverfunctions)
