import timers from 'timers/promises';
import strip_ansi from 'strip-ansi';
import { set_platform } from './platform.common.js';
export * from './platform.common.js';
function get_buffer(length) {
    return Buffer.allocUnsafe(length);
}
function encode(str) {
    // 用 Buffer.from 是因为可以利用 buffer pool，避免 encoder.encode 创建大量小且独立的 array buffer
    return Buffer.from(str);
}
async function delay(milliseconds, options) {
    return timers.setTimeout(milliseconds, undefined, options);
}
set_platform({
    nodejs: true,
    browser: false,
    get_buffer,
    encode,
    delay,
    strip_ansi,
    async get_websocket() {
        return (await import('ws'))
            .WebSocket;
    },
    async get_https_proxy_agent() {
        return (await import('https-proxy-agent'))
            .HttpsProxyAgent;
    }
});
//# sourceMappingURL=platform.js.map