all data hide
NPM Installation / build (16.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (16.x, windows-latest) (push) Has been cancelled
NPM Installation / build (17.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (17.x, windows-latest) (push) Has been cancelled
NPM Installation / build (18.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (18.x, windows-latest) (push) Has been cancelled

This commit is contained in:
2026-06-25 09:44:52 +07:00
parent 2f289fb09e
commit d26db06f74
20660 changed files with 1815162 additions and 41 deletions
+35
View File
@@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.replaceAll = exports.replace = void 0;
function replace(segments, pattern, ...replacers) {
const str = toString(segments);
const match = str.match(pattern);
if (match && match.index !== undefined) {
const start = match.index;
const end = start + match[0].length;
offsetStack();
overwrite(segments, [start, end], ...replacers.map(replacer => typeof replacer === 'function' ? replacer(match[0]) : replacer));
resetOffsetStack();
}
}
exports.replace = replace;
function replaceAll(segments, pattern, ...replacers) {
const str = toString(segments);
const allMatch = str.matchAll(pattern);
let length = str.length;
let lengthDiff = 0;
for (const match of allMatch) {
if (match.index !== undefined) {
const start = match.index + lengthDiff;
const end = start + match[0].length;
offsetStack();
overwrite(segments, [start, end], ...replacers.map(replacer => typeof replacer === 'function' ? replacer(match[0]) : replacer));
resetOffsetStack();
const newLength = getLength(segments);
lengthDiff += newLength - length;
length = newLength;
}
}
}
exports.replaceAll = replaceAll;
//# sourceMappingURL=replace.js.map