---
url: 'https://adk.nht.io/api/@nhtio/adk/lib/patch/functions/applyOperations.md'
---

# Function: applyOperations()

```ts
function applyOperations(
  files: Map<string, WorkspaceFile>,
  patch: ParsedApplyPatch,
): {
  files: Map<string, WorkspaceFile>;
  modifiedFiles: number;
};
```

Defined in: [src/lib/patch/index.ts:360](https://github.com/NHTIO/ADK/blob/v1.20261103.0/src/src/lib/patch/index.ts#L360)

Apply a parsed structured patch to a virtual workspace of files keyed by normalized path.

## Parameters

| Parameter | Type                                                                 | Description                       |
| --------- | -------------------------------------------------------------------- | --------------------------------- |
| `files`   | `Map`<`string`, [`WorkspaceFile`](../interfaces/WorkspaceFile.md)> | The workspace (mutated in place). |
| `patch`   | [`ParsedApplyPatch`](../interfaces/ParsedApplyPatch.md)              | The parsed envelope.              |

## Returns

```ts
{
  files: Map<string, WorkspaceFile>;
  modifiedFiles: number;
}
```

The workspace and the number of files touched.

| Name            | Type                                                                 | Defined in                                                                                                    |
| --------------- | -------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| `files`         | `Map`<`string`, [`WorkspaceFile`](../interfaces/WorkspaceFile.md)> | [src/lib/patch/index.ts:363](https://github.com/NHTIO/ADK/blob/v1.20261103.0/src/src/lib/patch/index.ts#L363) |
| `modifiedFiles` | `number`                                                             | [src/lib/patch/index.ts:363](https://github.com/NHTIO/ADK/blob/v1.20261103.0/src/src/lib/patch/index.ts#L363) |
