@gjsify/console 0.3.21 → 0.4.0
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.defineProperty,__name=(t,n)=>e(t,`name`,{value:n,configurable:!0});export{__name};
|
package/lib/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=typeof print==`function`&&typeof printerr==`function`;function _formatArgs(...e){let t=e[0],n=e.slice(1);if(typeof t!=`string`||!/%(s|d|i|f|o|O|c)/.test(t))return e.map(e=>typeof e==`string`?e:JSON.stringify(e)).join(` `);let r=0,i=t.replace(/%([sdifOoc])/g,(e,t)=>{if(r>=n.length)return e;let i=n[r++];switch(t){case`s`:return String(i);case`d`:case`i`:return String(parseInt(String(i),10));case`f`:return String(parseFloat(String(i)));case`o`:case`O`:return JSON.stringify(i);case`c`:return``;default:return e}}),a=n.slice(r);return a.length===0?i:i+` `+a.map(e=>typeof e==`string`?e:JSON.stringify(e)).join(` `)}var Console=class{_stdout;_stderr;_groupDepth=0;_groupIndentation;_timers=new Map;_counters=new Map;constructor(e,t){if(e&&typeof e.write==`function`)this._stdout=e,this._stderr=t||this._stdout;else if(e&&typeof e==`object`){let t=e;this._stdout=t.stdout,this._stderr=t.stderr||t.stdout}this._groupIndentation=2}_write(t,...n){let r=t===`stderr`&&this._stderr||this._stdout;if(r){let e=` `.repeat(this._groupDepth*this._groupIndentation),t=_formatArgs(...n);r.write(e+t+`
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";const e=typeof print==`function`&&typeof printerr==`function`;function _formatArgs(...e){let t=e[0],n=e.slice(1);if(typeof t!=`string`||!/%(s|d|i|f|o|O|c)/.test(t))return e.map(e=>typeof e==`string`?e:JSON.stringify(e)).join(` `);let r=0,i=t.replace(/%([sdifOoc])/g,(e,t)=>{if(r>=n.length)return e;let i=n[r++];switch(t){case`s`:return String(i);case`d`:case`i`:return String(parseInt(String(i),10));case`f`:return String(parseFloat(String(i)));case`o`:case`O`:return JSON.stringify(i);case`c`:return``;default:return e}}),a=n.slice(r);return a.length===0?i:i+` `+a.map(e=>typeof e==`string`?e:JSON.stringify(e)).join(` `)}var Console=class{_stdout;_stderr;_groupDepth=0;_groupIndentation;_timers=new Map;_counters=new Map;constructor(e,t){if(e&&typeof e.write==`function`)this._stdout=e,this._stderr=t||this._stdout;else if(e&&typeof e==`object`){let t=e;this._stdout=t.stdout,this._stderr=t.stderr||t.stdout}this._groupIndentation=2}_write(t,...n){let r=t===`stderr`&&this._stderr||this._stdout;if(r){let e=` `.repeat(this._groupDepth*this._groupIndentation),t=_formatArgs(...n);r.write(e+t+`
|
|
2
2
|
`)}else if(e){let e=` `.repeat(this._groupDepth*this._groupIndentation)+_formatArgs(...n);t===`stderr`?printerr(e):print(e)}else{let e=globalThis.console;t===`stderr`?e.error(...n):e.log(...n)}}log(...e){this._write(`stdout`,...e)}info(...e){this._write(`stdout`,...e)}debug(...e){this._write(`stdout`,...e)}warn(...e){this._write(`stderr`,...e)}error(...e){this._write(`stderr`,...e)}dir(e,t){this._write(`stdout`,e)}dirxml(...e){this.log(...e)}assert(e,...t){e||this.error(`Assertion failed:`,...t)}clear(){this._stdout?this._stdout.write(`\x1Bc`):e?print(`\x1Bc`):globalThis.console.clear()}count(e=`default`){let t=(this._counters.get(e)||0)+1;this._counters.set(e,t),this.log(`${e}: ${t}`)}countReset(e=`default`){this._counters.delete(e)}group(...e){e.length>0&&this.log(...e),this._groupDepth++}groupCollapsed(...e){this.group(...e)}groupEnd(){this._groupDepth>0&&this._groupDepth--}table(t,n){this._stdout?this._write(`stdout`,t):e?print(JSON.stringify(t,null,2)):globalThis.console.table(t,n)}time(e=`default`){this._timers.set(e,Date.now())}timeEnd(e=`default`){let t=this._timers.get(e);t===void 0?this.warn(`Warning: No such label '${e}' for console.timeEnd()`):(this.log(`${e}: ${Date.now()-t}ms`),this._timers.delete(e))}timeLog(e=`default`,...t){let n=this._timers.get(e);n===void 0?this.warn(`Warning: No such label '${e}' for console.timeLog()`):this.log(`${e}: ${Date.now()-n}ms`,...t)}trace(...e){let t=Error().stack?.split(`
|
|
3
3
|
`).slice(1).join(`
|
|
4
4
|
`)||``;this._write(`stderr`,`Trace:`,...e,`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/console",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Node.js console module for Gjs",
|
|
5
5
|
"module": "lib/esm/index.js",
|
|
6
6
|
"types": "lib/types/index.d.ts",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"console"
|
|
31
31
|
],
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@gjsify/cli": "^0.
|
|
34
|
-
"@gjsify/unit": "^0.
|
|
33
|
+
"@gjsify/cli": "^0.4.0",
|
|
34
|
+
"@gjsify/unit": "^0.4.0",
|
|
35
35
|
"@types/node": "^25.6.2",
|
|
36
36
|
"typescript": "^6.0.3"
|
|
37
37
|
}
|