UNPKG

@commercelayer/sdk

Version:
1 lines 1.73 kB
{"version":3,"sources":["../src/debug.ts"],"names":["__require"],"mappings":";;;;;AAOA,IAAM,gBAAA,GAAmB,CAAC,QAAA,EAAA,GAAqB,KAAA,KAAuB;AAEtE,CAAA;AAEA,IAAI,eAAA,GAAmC,CAAC,UAAA,KAAiC,gBAAA;AAIzE,IAAI;AACH,EAAA,MAAM,WAAA,GAAcA,4BAAQ,OAAO,CAAA;AACnC,EAAA,IAAI,WAAA,IAAgB,OAAO,WAAA,KAAgB,UAAA,EAAa,eAAA,GAAkB,WAAA;AAC3E,CAAA,CAAA,OAAS,KAAA,EAAO;AAEhB;AAGA,IAAM,WAAA,GAAc,OAAA;AAsBpB,IAAM,KAAA,GAAQ,CAAC,SAAA,KAAgC;AAC9C,EAAA,OAAO,eAAA,CAAgB,CAAA,EAAG,WAAW,CAAA,CAAA,EAAI,SAAS,CAAA,CAAE,CAAA;AACrD,CAAA;AAGA,IAAO,aAAA,GAAQ","file":"chunk-JVF5KY2J.cjs","sourcesContent":["\ntype Debugger = (pattern: string, ...args: any[]) => void\n\ntype DebuggerFactory = (namespace: string) => Debugger\n\n\n/* Nope debugger */\nconst debuggerFunction = (_pattern: string, ..._args: any[]): void => {\n\t// console.log(_pattern)\n}\n\nlet debuggerFactory: DebuggerFactory = (_namespace: string): Debugger => debuggerFunction\n\n\n/* Try loading 'debug' module */\ntry {\n\tconst debugModule = require('debug')\n\tif (debugModule && (typeof debugModule === 'function')) debuggerFactory = debugModule\n} catch (error) {\n\t//\n}\n\n\nconst debugPrefix = 'clsdk'\n\n\n/* Retrieve the name of the caller 'module' */\n/*\nconst caller = (): string => {\n\n\tconst err = new Error()\n\n\tError.prepareStackTrace = (_, stack) => stack\n\tconst stack = err.stack as unknown as NodeJS.CallSite[]\n\tError.prepareStackTrace = undefined\n\n\tconst fileName = stack[2].getFileName() || '/'\n\n\treturn fileName.replace(/^.*[\\\\/]/, '').replace('.ts', '')\n\n}\n*/\n\n\n/* Return a debugger for the defined namespace */\nconst debug = (namespace: string): Debugger => {\n\treturn debuggerFactory(`${debugPrefix}:${namespace}`)\n}\n\n\nexport default debug\n"]}