UNPKG

read-browser-cookies

Version:

Node.js version of `--cookies-from-browser` from yt-dlp

43 lines (42 loc) 1.43 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.execCrossPlatform = exports.defineCrossPlatform = exports.noop = exports.notImplemented = exports.baseDebug = void 0; const debug_1 = __importDefault(require("debug")); exports.baseDebug = (0, debug_1.default)('read-browser-cookies'); function notImplemented() { throw new Error('not implemented'); } exports.notImplemented = notImplemented; function noop() { // empty placeholder } exports.noop = noop; const defaultNotImplement = notImplemented; function defineCrossPlatform(options) { const notImplemented = defaultNotImplement; // win if (['cygwin', 'win32'].includes(process.platform)) { return options.win || notImplemented; } // mac else if (process.platform === 'darwin') { return options.mac || notImplemented; } // linux else { return options.linux || notImplemented; } } exports.defineCrossPlatform = defineCrossPlatform; function execCrossPlatform(options, useNoop = false) { if (useNoop) { options.mac || (options.mac = noop); options.win || (options.win = noop); options.linux || (options.linux = noop); } defineCrossPlatform(options)(); } exports.execCrossPlatform = execCrossPlatform;