@matheusvcouto/debug 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # @matheusvcouto/debug
2
+
3
+ no description
4
+
5
+ ## Instalação
6
+
7
+ ```bash
8
+ bun add @matheusvcouto/debug
9
+ # ou
10
+ npm install @matheusvcouto/debug
11
+ ```
package/index.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ type DebugTags<AvailableTags extends readonly string[]> = AvailableTags[number];
2
+ type DebugTagInput<AvailableTags extends readonly string[]> = DebugTags<AvailableTags> | (string & {});
3
+ interface Debugger {
4
+ log: (...args: any[]) => void;
5
+ warn: (...args: any[]) => void;
6
+ error: (...args: any[]) => void;
7
+ info: (...args: any[]) => void;
8
+ }
9
+ export declare function createDebug<AvailableTags extends readonly string[]>(debugEnvVar: string, knownTags: AvailableTags): {
10
+ DEBUG: Record<DebugTags<AvailableTags>, boolean> & Record<string, boolean>;
11
+ debug: (tag: DebugTagInput<AvailableTags>) => Debugger;
12
+ isEnabled: (tag: DebugTagInput<AvailableTags>) => boolean;
13
+ };
14
+ export {};
package/index.js ADDED
@@ -0,0 +1 @@
1
+ function K(C,J){let F=new Date().toLocaleDateString("pt-BR",{hour:"2-digit",minute:"2-digit",second:"2-digit"});function z(k,q){if(q.has("*"))return!0;let w=k.toUpperCase();if(q.has(w))return!0;let j=w.split(",")[0]??w.split(":")[0];if(j&&q.has(j))return!0;return!1}let A=new Set(C.split(",").map((k)=>k.trim().toUpperCase()).filter(Boolean)),H=new Proxy({},{get:(k,q)=>{if(typeof q!=="string")return!1;return z(q,A)}});function I(k){let q=z(k,A),w=`[${F}]:[${k}]`;if(!q)return{log:()=>{},warn:()=>{},error:()=>{},info:()=>{}};return{log:(...j)=>console.log(w,...j),warn:(...j)=>console.warn(w,...j),error:(...j)=>console.error(w,...j),info:(...j)=>console.info(w,...j)}}return{DEBUG:H,debug:I,isEnabled:(k)=>z(k,A)}}export{K as createDebug};
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@matheusvcouto/debug",
3
+ "version": "1.0.1",
4
+ "description": "no description",
5
+ "type": "module",
6
+ "main": "./index.js",
7
+ "types": "./index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./index.d.ts",
11
+ "import": "./index.js",
12
+ "default": "./index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "**/*.js",
17
+ "**/*.d.ts",
18
+ "README.md",
19
+ "LICENSE"
20
+ ],
21
+ "keywords": [
22
+ "typescript",
23
+ "bun",
24
+ "utils"
25
+ ],
26
+ "author": "Matheus Couto",
27
+ "license": "MIT",
28
+ "repository": "",
29
+ "peerDependencies": {
30
+ "typescript": "^5"
31
+ }
32
+ }