UNPKG

grab-url

Version:

📥 Generate Request to API from Browser

3 lines (2 loc) 4.11 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=(e=>(e.RESET="reset",e.BLACK="black",e.RED="red",e.GREEN="green",e.YELLOW="yellow",e.BLUE="blue",e.MAGENTA="magenta",e.CYAN="cyan",e.WHITE="white",e.GRAY="gray",e.BRIGHT_RED="brightRed",e.BRIGHT_GREEN="brightGreen",e.BRIGHT_YELLOW="brightYellow",e.BRIGHT_BLUE="brightBlue",e.BRIGHT_MAGENTA="brightMagenta",e.BRIGHT_CYAN="brightCyan",e.BRIGHT_WHITE="brightWhite",e.BG_RED="bgRed",e.BG_GREEN="bgGreen",e.BG_YELLOW="bgYellow",e.BG_BLUE="bgBlue",e.BG_MAGENTA="bgMagenta",e.BG_CYAN="bgCyan",e.BG_WHITE="bgWhite",e.BG_GRAY="bgGray",e.BG_BLACK="bgBlack",e.BG_BRIGHT_RED="bgBrightRed",e.BG_BRIGHT_GREEN="bgBrightGreen",e.BG_BRIGHT_YELLOW="bgBrightYellow",e.BG_BRIGHT_BLUE="bgBrightBlue",e.BG_BRIGHT_MAGENTA="bgBrightMagenta",e.BG_BRIGHT_CYAN="bgBrightCyan",e.BG_BRIGHT_WHITE="bgBrightWhite",e))(e||{});const t={reset:[0,"000000"],black:[30,"000000"],red:[31,"ff0000"],green:[32,"00ff00"],yellow:[33,"ffff00"],blue:[34,"0000ff"],magenta:[35,"ff00ff"],cyan:[36,"00ffff"],white:[37,"ffffff"],gray:[90,"808080"],brightRed:[91,"ff5555"],brightGreen:[92,"55ff55"],brightYellow:[93,"ffff55"],brightBlue:[94,"5555ff"],brightMagenta:[95,"ff55ff"],brightCyan:[96,"55ffff"],brightWhite:[97,"ffffff"],bgBlack:[40,"000000"],bgRed:[41,"ff0000"],bgGreen:[42,"00ff00"],bgYellow:[43,"ffff00"],bgBlue:[44,"0000ff"],bgMagenta:[45,"ff00ff"],bgCyan:[46,"00ffff"],bgWhite:[47,"ffffff"],bgGray:[100,"808080"],bgBrightRed:[101,"ff8888"],bgBrightGreen:[102,"88ff88"],bgBrightYellow:[103,"ffff88"],bgBrightBlue:[104,"8888ff"],bgBrightMagenta:[105,"ff88ff"],bgBrightCyan:[106,"88ffff"],bgBrightWhite:[107,"ffffff"]};function r(e="ansi"){const r={};for(const[f,[n,o]]of Object.entries(t))r[f]="html"===e?"#"+o:"["+n+"m";return r}function f(e){const t=r();return"string"==typeof e?t.yellow:"number"==typeof e?t.cyan:"boolean"==typeof e?t.magenta:"function"==typeof e?t.red:null===e?t.gray:Array.isArray(e)?t.blue:"object"==typeof e?t.green:t.white}function n(e){return"string"==typeof e?'""':"number"==typeof e?"number":"boolean"==typeof e?"bool":"function"==typeof e?"function":null===e?"null":Array.isArray(e)?e.length?"["+n(e[0])+"]":"[]":"object"==typeof e?"{...}":typeof e}function o(e,t=0,g="ansi"){const l=r(g),i=" ".repeat(t);var a="";if("object"!=typeof e||null===e){return f(e)+n(e)+l.reset}if(Array.isArray(e)){if(a=l.blue+"["+l.reset,e.length&&(a+="\n"),!e.every(t=>typeof t==typeof e[0]))return e.forEach((r,f)=>{a+=i+" "+o(r,t+1),f<e.length-1&&(a+=","),a+="\n"}),a+=i+l.blue+"]"+l.reset;a+=i+" "+o(e[0],t+1),a+=",",a+="\n"}a=l.green+"{"+l.reset;const b=Object.keys(e);return b.length&&(a+="\n"),b.forEach((r,g)=>{const s=e[r],y=f(s);a+=i+" ","object"!=typeof s||null===s||Array.isArray(s)?Array.isArray(s)?a+=y+r+l.reset+": "+o(s,t+1):a+=y+r+": "+n(s)+l.reset:a+=y+r+l.reset+": "+o(s,t+1),g<b.length-1&&(a+=","),a+="\n"}),a+=i+l.green+"}"+l.reset}exports.ColorName=e,exports.getColors=r,exports.log=function(e="",t={}){let{color:f,style:n="color:rgb(54, 165, 220); font-size: 10pt;",hideInProduction:g,startSpinner:l=!1,stopSpinner:i=!1}=t;const a=r();void 0===g&&(g="undefined"!=typeof window&&window?.location.hostname.includes("localhost")),"object"==typeof e&&(e=o(e)+"\n\n"+JSON.stringify(e,null,2)),Array.isArray(f)&&1==f.length&&(f=f[0]),f&&void 0!==typeof process&&(e.includes("%c")&&Array.isArray(f)?e=e.replace(/%c/g,(e,t)=>a[f[t]]||""):f&&"string"==typeof f&&(e=(a[f]||"")+e+a.reset));var b=0;return l?(global||globalThis).interval=setInterval(()=>{process.stdout.write((Array.isArray(f)?a[f[0]]:a[f]||"")+"\r"+"⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏".split("")[b=++b%10]+" "+e+a.reset)},50):i?(clearInterval((global||globalThis).interval),process.stdout.write("\r"+(e||" ")+" ".repeat(e.length+20)+"\n")):"string"==typeof n?(1==n.split(" ").length||f?n=`color: ${f||n}; font-size: 11pt;`:n.match(/^#[0-9a-fA-F]{6}$/)&&(n=`color: ${n}; font-size: 11pt;`),g?console.debug((n?"%c":"")+(e||""),n):console.log((n?"%c":"")+(e||""),n)):"object"==typeof n&&console.log(e,...n),!0},exports.printJSONStructure=o; //# sourceMappingURL=log.cjs.js.map