Files
HRM-System/node_modules/prettier-plugin-organize-imports/lib/apply-text-changes.js
2026-04-13 08:19:53 +08:00

14 lines
420 B
JavaScript

/**
* Apply the given set of text changes to the input.
*
* @param {string} input
* @param {readonly import('typescript').TextChange[]} changes
*/
module.exports.applyTextChanges = (input, changes) =>
changes.reduceRight((text, change) => {
const head = text.slice(0, change.span.start);
const tail = text.slice(change.span.start + change.span.length);
return `${head}${change.newText}${tail}`;
}, input);