🐛 Fix bugs, typos, and refine type definitions in deno libraries

This commit is contained in:
2026-04-28 23:08:51 +08:00
parent 66f9443dc3
commit 1a252523db
2 changed files with 11 additions and 11 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ import {
term,
} from "https://script.hatter.ink/@71/deno-commons-mod.ts";
export async function howto(message: string): Promise<string> {
export async function howto(message: string): Promise<string | null> {
const response = await fetchDataWithTimeout(
"https://hatter.ink/ai/command-line-howto.json",
{
+10 -10
View File
@@ -35,7 +35,7 @@ export function stdin(): ReadableStream {
return isDeno() ? Deno.stdin.readable : process.stdin;
}
function streamToArrayBuffer(stream) {
function streamToArrayBuffer(stream): Promise<ArrayBuffer> {
const chunks = [];
return new Promise((resolve, reject) => {
stream.on("error", (err) => reject(err));
@@ -291,15 +291,15 @@ export function formatHumanTime2(timeMillis: number): string {
if (timeMinutes < 60) {
return `${timeMinutes} minutes`;
}
const timeHours = timeMinutes / 60;
const timeHours = Math.floor(timeMinutes / 60);
if (timeHours < 24) {
return `${formatNumber(timeHours)} hours`;
}
const timeDays = timeHours / 24;
const timeDays = Math.floor(timeHours / 24);
if (timeDays < 365) {
return `${formatNumber(timeDays)} days`;
}
const timeYears = timeDays / 365;
const timeYears = Math.floor(timeDays / 365);
return `${formatNumber(timeYears)} years`;
}
@@ -588,7 +588,7 @@ function __getColorCode(color: string): string {
return COLOR_MAP[color];
}
function renderColorTokens(tokens: ColorToken[], renderColor: bool): string {
function renderColorTokens(tokens: ColorToken[], renderColor: boolean): string {
const text: string[] = [];
const colorMapStack = new Map<string, number[]>();
for (const token of tokens) {
@@ -849,7 +849,7 @@ function __isDenoNotFound(e) {
}
function __isNodeNotFound(e) {
return (e.errno ?? 0 === -2) && e.message &&
return ((e.errno ?? 0) === -2) && e.message &&
e.message.includes("no such file or directory");
}
@@ -924,7 +924,7 @@ export async function writeStringToFile(
export async function removePath(path: string): Promise<void> {
if (isDeno()) {
await Deno.remove(newFilename);
await Deno.remove(path);
} else {
return new Promise((resolve, reject) => {
rm(path, (err) => {
@@ -964,7 +964,7 @@ export function uint8ArrayToHexString(uint8: Uint8Array): string {
.join("");
}
export function uint8ArrayToBase32String(uint8: Unit8Array): string {
export function uint8ArrayToBase32String(uint8: Uint8Array): string {
return encodeBase32(uint8).replaceAll(/=/g, "").toLowerCase();
}
@@ -1523,7 +1523,7 @@ export async function fetchAlibabaCloudInstanceIdentityV1(
pkcs7Options,
);
if (pkcs7Response.status != 200) {
throw new Error("Get PKCS#7 failed: ${pkcs7Response.status}`)");
throw new Error(`Get PKCS#7 failed: ${pkcs7Response.status}`);
}
return await pkcs7Response.text();
}
@@ -1636,7 +1636,7 @@ export interface GetSecretValueOptions {
maxCacheTimeSecs?: number;
}
export function getRunEnv(): stirng | null {
export function getRunEnv(): string | null {
return getEnv("RUN_ENV");
}