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/api-management/node_modules/peberminta/lib/char.mjs
import { token, remainingTokensNumber, map, flatten, parserPosition as parserPosition$1, tryParse as tryParse$1, match as match$1 } from './core.mjs';
import { clamp, escapeWhitespace } from './util.mjs';

function char(char) {
    return token((c) => (c === char) ? c : undefined);
}
function oneOf(chars) {
    return token((c) => (chars.includes(c)) ? c : undefined);
}
function noneOf(chars) {
    return token((c) => (chars.includes(c)) ? undefined : c);
}
function charTest(regex) {
    return token((c) => regex.test(c) ? c : undefined);
}
function str(str) {
    const len = str.length;
    return (data, i) => {
        const tokensNumber = remainingTokensNumber(data, i);
        let substr = '';
        let j = 0;
        while (j < tokensNumber && substr.length < len) {
            substr += data.tokens[i + j];
            j++;
        }
        return (substr === str)
            ? {
                matched: true,
                position: i + j,
                value: str
            }
            : { matched: false };
    };
}
function concat(...ps) {
    return map(flatten(...ps), (vs) => vs.join(''));
}
function parserPosition(data, i, contextTokens = 11) {
    const len = data.tokens.length;
    const lowIndex = clamp(0, i - contextTokens, len - contextTokens);
    const highIndex = clamp(contextTokens, i + 1 + contextTokens, len);
    const tokensSlice = data.tokens.slice(lowIndex, highIndex);
    if (tokensSlice.some((t) => t.length !== 1)) {
        return parserPosition$1(data, i, (t) => t);
    }
    let line = '';
    let offset = 0;
    let markerLen = 1;
    if (i < 0) {
        line += ' ';
    }
    if (0 < lowIndex) {
        line += '...';
    }
    for (let j = 0; j < tokensSlice.length; j++) {
        const token = escapeWhitespace(tokensSlice[j]);
        if (lowIndex + j === i) {
            offset = line.length;
            markerLen = token.length;
        }
        line += token;
    }
    if (highIndex < len) {
        line += '...';
    }
    if (len <= i) {
        offset = line.length;
    }
    return `${''.padEnd(offset)}${i}\n${line}\n${''.padEnd(offset)}${'^'.repeat(markerLen)}`;
}
function parse(parser, str, options) {
    const data = { tokens: [...str], options: options };
    const result = parser(data, 0);
    if (!result.matched) {
        throw new Error('No match');
    }
    if (result.position < data.tokens.length) {
        throw new Error(`Partial match. Parsing stopped at:\n${parserPosition(data, result.position)}`);
    }
    return result.value;
}
function tryParse(parser, str, options) {
    return tryParse$1(parser, [...str], options);
}
function match(matcher, str, options) {
    return match$1(matcher, [...str], options);
}

export { oneOf as anyOf, char, charTest, concat, match, noneOf, oneOf, parse, parserPosition, str, tryParse };