Skip to content

Commit

Permalink
addToGlobalScope()
Browse files Browse the repository at this point in the history
  • Loading branch information
astoilkov committed Dec 18, 2024
1 parent 767966c commit 4277040
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
4 changes: 4 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ export type { InspectInspect } from "./src/inspect/ii";
export { default as tt } from "./src/inspect/tt";
export type { TableTable } from "./src/inspect/tt";

// global
export { default as addToGlobalScope } from "./src/global/addToGlobalScope";
export { default as addNoopToGlobalScope } from "./src/global/addNoopToGlobalScope";

// inspect
export { default as consoleInspect } from "./src/inspect/consoleInspect";
export type { ConsoleInspectOptions } from "./src/inspect/consoleInspect";
Expand Down
19 changes: 19 additions & 0 deletions src/global/addNoopToGlobalScope.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { InspectInspect } from "../inspect/ii";
import type { TableTable } from "../inspect/tt";

declare const ii: InspectInspect;
declare const tt: TableTable

export default function addNoopToGlobalScope(): void {
const ii = <T>(value: T) => value;
ii.defaults = {};
ii.depth = () => ii;
ii.d = ii.depth;
ii.keys = () => ii;
ii.k = ii.keys;
(global as any).ii = ii;

const tt = <T>(value: T) => value;
tt.defaults = {};
(global as any).tt = tt;
}
11 changes: 11 additions & 0 deletions src/global/addToGlobalScope.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import iiFn from "../inspect/ii";
import ttFn, { type TableTable } from "../inspect/tt";
import type { InspectInspect } from "../inspect/ii";

declare const ii: InspectInspect;
declare const tt: TableTable;

export default function addToGlobalScope(): void {
(global as any).ii = iiFn;
(global as any).tt = ttFn;
}

0 comments on commit 4277040

Please sign in to comment.