Skip to content

Commit 860d4c7

Browse files
committed
fix: "slow" types
1 parent 282c575 commit 860d4c7

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/colours.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const colors = [
1212
];
1313

1414
// https://github.com/debug-js/debug/blob/4.3.4/src/common.js#L41
15-
export function selectColour(ns: string) {
15+
export function selectColour(ns: string): number {
1616
let hash = 0;
1717

1818
for (let i = 0; i < ns.length; i++) {
@@ -23,7 +23,7 @@ export function selectColour(ns: string) {
2323
return colors[Math.abs(hash) % colors.length];
2424
}
2525

26-
export const colourNs = (ns: string) => {
26+
export const colourNs = (ns: string): string => {
2727
const color = selectColour(ns);
2828
const r = color >> 16;
2929
const g = (color >> 8) & 0xff;

src/env.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { context } from "./types.ts";
22

3-
const getDenoEnv = (variable: string) => {
3+
const getDenoEnv = (variable: string): string => {
44
const Deno = context.Deno;
55
const state = Deno!.permissions.querySync?.({ name: "env", variable })?.state;
66
if (state === "prompt") return "";
@@ -9,7 +9,7 @@ const getDenoEnv = (variable: string) => {
99

1010
const deno = "Deno" in globalThis;
1111

12-
export const getEnv = (variable: string) => {
12+
export const getEnv = (variable: string): string => {
1313
if (deno) return getDenoEnv(variable);
1414
return context.process?.env[variable] || context.env?.[variable] || "";
1515
};

src/namespacing.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export class Namespaces {
77
this.update(debugspec);
88
}
99

10-
update(debugspec: string) {
10+
update(debugspec: string): void {
1111
const parsed = this.parsed;
1212
const debugs = debugspec.split(/[\s,]+/).map(each => each.trim());
1313
for (const item of debugs) {
@@ -28,7 +28,7 @@ export class Namespaces {
2828
this.parsed = parsed;
2929
}
3030

31-
check(namespace: string) {
31+
check(namespace: string): boolean {
3232
const chain = namespace.split(":").map(part => part.trim());
3333
let current = this.parsed;
3434
let tentative = false;

src/w.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import { context } from "./types.ts";
22
import { colourNs, selectColour } from "./colours.ts";
33
import { getEnv } from "./env.ts";
44
import { Namespaces } from "./namespacing.ts";
5-
const DEBUG = getEnv("DEBUG");
5+
const DEBUG: string = getEnv("DEBUG");
66
const stderr = context.process?.stderr;
77
const useColour = stderr?.isTTY && !getEnv("NO_COLOR");
88
const debug = context.console.Console?.(stderr)?.debug || context.console.debug;
99

10-
export const namespaces = new Namespaces(DEBUG);
10+
export const namespaces: Namespaces = new Namespaces(DEBUG);
1111

1212
export interface DebugFn {
1313
(...args: unknown[]): void;

0 commit comments

Comments
 (0)