mirror of
https://github.com/mivodev/mivodev.github.io.git
synced 2026-01-26 21:41:53 +07:00
34 lines
772 B
JavaScript
34 lines
772 B
JavaScript
// Separating some utils for improved tree shaking of the `./internals` export
|
|
|
|
const noncapturingDelim = String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;
|
|
|
|
/**
|
|
Updates the array in place by incrementing each value greater than or equal to the threshold.
|
|
@param {Array<number>} arr
|
|
@param {number} threshold
|
|
*/
|
|
function incrementIfAtLeast(arr, threshold) {
|
|
for (let i = 0; i < arr.length; i++) {
|
|
if (arr[i] >= threshold) {
|
|
arr[i]++;
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
@param {string} str
|
|
@param {number} pos
|
|
@param {string} oldValue
|
|
@param {string} newValue
|
|
@returns {string}
|
|
*/
|
|
function spliceStr(str, pos, oldValue, newValue) {
|
|
return str.slice(0, pos) + newValue + str.slice(pos + oldValue.length);
|
|
}
|
|
|
|
export {
|
|
incrementIfAtLeast,
|
|
noncapturingDelim,
|
|
spliceStr,
|
|
};
|