HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux ip-172-31-4-197 6.8.0-1036-aws #38~22.04.1-Ubuntu SMP Fri Aug 22 15:44:33 UTC 2025 x86_64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/web.enelar.com.co/node_modules/@nx/devkit/src/utils/string-change.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.applyChangesToString = exports.ChangeType = void 0;
var ChangeType;
(function (ChangeType) {
    ChangeType["Delete"] = "Delete";
    ChangeType["Insert"] = "Insert";
})(ChangeType || (exports.ChangeType = ChangeType = {}));
/**
 * Applies a list of changes to a string's original value.
 *
 * This is useful when working with ASTs.
 *
 * For Example, to rename a property in a method's options:
 *
 * ```typescript
 * const code = `bootstrap({
 *   target: document.querySelector('#app')
 * })`;
 *
 * const indexOfPropertyName = 13; // Usually determined by analyzing an AST.
 * const updatedCode = applyChangesToString(code, [
 *   {
 *     type: ChangeType.Insert,
 *     index: indexOfPropertyName,
 *     text: 'element'
 *   },
 *   {
 *     type: ChangeType.Delete,
 *     start: indexOfPropertyName,
 *     length: 6
 *   },
 * ]);
 *
 * bootstrap({
 *   element: document.querySelector('#app')
 * });
 * ```
 */
function applyChangesToString(text, changes) {
    assertChangesValid(changes);
    const sortedChanges = changes.sort((a, b) => {
        const diff = getChangeIndex(a) - getChangeIndex(b);
        if (diff === 0) {
            if (a.type === b.type) {
                return 0;
            }
            else {
                // When at the same place, Insert before Delete
                return isStringInsertion(a) ? -1 : 1;
            }
        }
        return diff;
    });
    let offset = 0;
    for (const change of sortedChanges) {
        const index = getChangeIndex(change) + offset;
        if (isStringInsertion(change)) {
            text = text.slice(0, index) + change.text + text.slice(index);
            offset += change.text.length;
        }
        else {
            text = text.slice(0, index) + text.slice(index + change.length);
            offset -= change.length;
        }
    }
    return text;
}
exports.applyChangesToString = applyChangesToString;
function assertChangesValid(changes) {
    for (const change of changes) {
        if (isStringInsertion(change)) {
            if (!Number.isInteger(change.index)) {
                throw new TypeError(`${change.index} must be an integer.`);
            }
            if (change.index < 0) {
                throw new Error(`${change.index} must be a positive integer.`);
            }
            if (typeof change.text !== 'string') {
                throw new Error(`${change.text} must be a string.`);
            }
        }
        else {
            if (!Number.isInteger(change.start)) {
                throw new TypeError(`${change.start} must be an integer.`);
            }
            if (change.start < 0) {
                throw new Error(`${change.start} must be a positive integer.`);
            }
            if (!Number.isInteger(change.length)) {
                throw new TypeError(`${change.length} must be an integer.`);
            }
            if (change.length < 0) {
                throw new Error(`${change.length} must be a positive integer.`);
            }
        }
    }
}
function getChangeIndex(change) {
    if (isStringInsertion(change)) {
        return change.index;
    }
    else {
        return change.start;
    }
}
function isStringInsertion(change) {
    return change.type === ChangeType.Insert;
}