function · Node only

# jsonFile

One JSON file, written whole and atomically (to a temporary file, then renamed).

`@toip-tools/mesh-transport/node` · [View source](https://github.com/yourbuddyconner/toip-tools/blob/main/packages/mesh-transport/src/node.ts#L91)

Import:

```ts
import { jsonFile } from "@toip-tools/mesh-transport/node";
```

## Declaration

Signature:

```ts
jsonFile<T>(path: string, empty: T): {
    load(): Promise<T>;
    save(value: T): Promise<void>;
};
```

### Parameters

- **`path` (required)**: `string`
- **`empty` (required)**: `T`

### Returns

`{ load(): Promise<T>; save(value: T): Promise<void>; }`

## Returned object

The returned object exposes these properties and methods.

## Methods

### `load`

Signature:

```ts
load(): Promise<T>;
```

No parameters.

#### Returns

`Promise<T>`

### `save`

Signature:

```ts
save(value: T): Promise<void>;
```

#### Parameters

- **`value` (required)**: `T`

#### Returns

`Promise<void>`

[Usage guide](https://toip.tools/toolkit/mesh-transport/#usage) · [Error handling](https://toip.tools/toolkit/mesh-transport/#errors) · [All exports](https://toip.tools/toolkit/mesh-transport/api/node/)

---

This is the Markdown version of https://toip.tools/toolkit/mesh-transport/api/node/jsonFile/. An index of the documentation for AI assistants is at https://toip.tools/llms.txt.
