Skip to content

Commit 69cd2ab

Browse files
committed
fix: Allow more console methods
1 parent 66d251a commit 69cd2ab

File tree

2 files changed

+18
-27
lines changed

2 files changed

+18
-27
lines changed

deno.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@denosaurs/wait",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"exports": {
55
".": "./mod.ts",
66
"./spinners": "./spinners.ts",

mod.ts

+17-26
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,7 @@ export interface PersistOptions {
4646
text?: string;
4747
}
4848

49-
export interface Console {
50-
log: typeof console.log;
51-
warn: typeof console.warn;
52-
error: typeof console.error;
53-
info: typeof console.info;
54-
debug: typeof console.debug;
55-
time: typeof console.time;
56-
timeEnd: typeof console.timeEnd;
57-
trace: typeof console.trace;
58-
dir: typeof console.dir;
59-
assert: typeof console.assert;
60-
count: typeof console.count;
61-
countReset: typeof console.countReset;
62-
table: typeof console.table;
63-
dirxml: typeof console.dirxml;
64-
timeLog: typeof console.timeLog;
65-
}
49+
export type Console = typeof globalThis.console;
6650

6751
export function wait(opts: string | SpinnerOptions): Spinner {
6852
if (typeof opts === "string") {
@@ -140,24 +124,31 @@ export class Spinner {
140124
#interceptConsole(): void {
141125
const methods: (keyof Console)[] = [
142126
"log",
143-
"warn",
144-
"error",
145-
"info",
146127
"debug",
147-
"time",
148-
"timeEnd",
149-
"trace",
128+
"info",
150129
"dir",
130+
"dirxml",
131+
"warn",
132+
"error",
151133
"assert",
152134
"count",
153135
"countReset",
154136
"table",
155-
"dirxml",
137+
"time",
156138
"timeLog",
139+
"timeEnd",
140+
"group",
141+
"groupCollapsed",
142+
"groupEnd",
143+
"clear",
144+
"trace",
145+
"profile",
146+
"profileEnd",
147+
"timeStamp",
157148
];
158149
for (const method of methods) {
159-
const original = (console as Console)[method];
160-
(console as Console)[method] = (...args: unknown[]) => {
150+
const original = console[method] as (...args: unknown[]) => void;
151+
console[method] = (...args: unknown[]) => {
161152
if (this.isSpinning) {
162153
this.stop();
163154
this.clear();

0 commit comments

Comments
 (0)