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

# Function: applyUpdateHunks()

```ts
function applyUpdateHunks(inputText: string, hunks: ParsedHunk[]): string;
```

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

Apply an update operation's hunks to `inputText`. Context matching is exact and rejects
ambiguity: a hunk whose old-lines match more than one location past the cursor fails
rather than guessing.

The input's line-ending convention is preserved: a file containing CRLF is rejoined with CRLF,
so a one-line edit stays a one-line diff rather than a whole-file newline rewrite.

## Parameters

| Parameter   | Type                                          | Description                 |
| ----------- | --------------------------------------------- | --------------------------- |
| `inputText` | `string`                                      | The file's current text.    |
| `hunks`     | [`ParsedHunk`](../interfaces/ParsedHunk.md)\[] | The parsed hunks, in order. |

## Returns

`string`

The patched text, using the input's dominant line terminator.
