(
source: string,
patch: string | StructuredPatch | [StructuredPatch],
options: ApplyPatchOptions = {}
)
| 52 | * @param patch a string diff or the output from the `parsePatch` or `structuredPatch` methods. |
| 53 | */ |
| 54 | export function applyPatch( |
| 55 | source: string, |
| 56 | patch: string | StructuredPatch | [StructuredPatch], |
| 57 | options: ApplyPatchOptions = {} |
| 58 | ): string | false { |
| 59 | let patches: StructuredPatch[]; |
| 60 | if (typeof patch === 'string') { |
| 61 | patches = parsePatch(patch); |
| 62 | } else if (Array.isArray(patch)) { |
| 63 | patches = patch; |
| 64 | } else { |
| 65 | patches = [patch]; |
| 66 | } |
| 67 | |
| 68 | if (patches.length > 1) { |
| 69 | throw new Error('applyPatch only works with a single input.'); |
| 70 | } |
| 71 | |
| 72 | return applyStructuredPatch(source, patches[0], options); |
| 73 | } |
| 74 | |
| 75 | function applyStructuredPatch( |
| 76 | source: string, |
no test coverage detected