update deno-commons-mod.ts

This commit is contained in:
2026-02-01 01:18:25 +08:00
parent 729d4b4ac9
commit 5d38a3a250

View File

@@ -4,7 +4,7 @@
import {assert} from "jsr:@std/assert/assert";
import {assertEquals} from "jsr:@std/assert";
import {decodeBase64, encodeBase64} from "jsr:@std/encoding/base64";
import {dirname} from "https://deno.land/std@0.208.0/path/mod.ts";
import {dirname, fromFileUrl} from "https://deno.land/std/path/mod.ts";
// reference: https://docs.deno.com/examples/hex_base64_encoding/
// import { decodeBase64, encodeBase64 } from "jsr:@std/encoding/base64";
@@ -589,6 +589,14 @@ export async function fetchWithTimeout(
return response;
}
export function getCurrentScriptFile(): string {
return fromFileUrl(import.meta.url);
}
export function getCurrentScriptDirectory(): string {
return dirname(getCurrentScriptFile());
}
Deno.test("isOn", () => {
assertEquals(false, isOn(undefined));
assertEquals(false, isOn(""));