[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/native-worldgen](https://jsprismarine.dev/api/@jsprismarine/native-worldgen/index.md) / embed

# embed

## Functions

### libraryForPlatform()

> **libraryForPlatform**(`platform`): `Promise`\<`Uint8Array`\<`ArrayBufferLike`\> \| `undefined`\>

Defined in: [embed.ts:10](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/native-worldgen/src/embed.ts#L10)

The bytes of a platform's library, for a packager to embed in an executable: the build in the
package if it is the published one or a local `build:native`, else the published build,
downloaded and checked.

#### Parameters

##### platform

`string`

The platform key the executable is for.

#### Returns

`Promise`\<`Uint8Array`\<`ArrayBufferLike`\> \| `undefined`\>

The library, or undefined when there is no build for that platform.

***

### libraryForPlatform()

> **libraryForPlatform**(`platform`): `Promise`\<`Uint8Array`\<`ArrayBufferLike`\> \| `undefined`\>

Defined in: [script-host/src/embed.ts:10](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/embed.ts#L10)

The bytes of a platform's library, for a packager to embed in an executable: the build in the
package if it is the published one or a local `build:native`, else the published build,
downloaded and checked.

#### Parameters

##### platform

`string`

The platform key the executable is for.

#### Returns

`Promise`\<`Uint8Array`\<`ArrayBufferLike`\> \| `undefined`\>

The library, or undefined when there is no build for that platform.

***

### provideEmbeddedLibrary()

> **provideEmbeddedLibrary**(`library`, `cacheDir`, `env?`): `string`

Defined in: [embed.ts:22](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/native-worldgen/src/embed.ts#L22)

Writes an embedded library to a cache directory under its digest, and points
`JSP_NATIVE_WORLDGEN_LIBRARY` at it, unless the user already set it. An operating system loads
a shared library only from a file, so an executable has to write it once.

#### Parameters

##### library

`Uint8Array`

The embedded bytes.

##### cacheDir

`string`

A writable directory.

##### env?

`ProcessEnv`

The environment to set the variable in.

#### Returns

`string`

The file's path.

***

### provideEmbeddedLibrary()

> **provideEmbeddedLibrary**(`library`, `cacheDir`, `env?`): `string`

Defined in: [script-host/src/embed.ts:22](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/embed.ts#L22)

Writes an embedded library to a cache directory under its digest, and points
`JSP_SCRIPT_HOST_LIBRARY` at it, unless the user already set it. An operating system loads
a shared library only from a file, so an executable has to write it once.

#### Parameters

##### library

`Uint8Array`

The embedded bytes.

##### cacheDir

`string`

A writable directory.

##### env?

`ProcessEnv`

The environment to set the variable in.

#### Returns

`string`

The file's path.
