mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 23:00:30 +00:00
16 lines
336 B
TypeScript
16 lines
336 B
TypeScript
import type { Operation } from './diff';
|
|
|
|
export function patch(a: string, operations: Operation[]) {
|
|
let result = '';
|
|
|
|
for (const op of operations) {
|
|
if (op.type === 'COPY') {
|
|
result += a.slice(op.start, op.start + op.len);
|
|
} else if (op.type === 'INSERT') {
|
|
result += op.content;
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|