update deno commons mod
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
// Reference:
|
// Reference:
|
||||||
// - https://docs.deno.com/runtime/fundamentals/testing/
|
// - https://docs.deno.com/runtime/fundamentals/testing/
|
||||||
|
|
||||||
import {decodeBase64, encodeBase64} from "jsr:@std/encoding/base64";
|
import { decodeBase64, encodeBase64 } from "jsr:@std/encoding/base64";
|
||||||
import {dirname, fromFileUrl} from "jsr:@std/path";
|
import { dirname, fromFileUrl } from "jsr:@std/path";
|
||||||
import {toArrayBuffer} from "jsr:@std/streams";
|
import { toArrayBuffer } from "jsr:@std/streams";
|
||||||
import {spawn, SpawnOptionsWithoutStdio} from "node:child_process";
|
import { spawn, SpawnOptionsWithoutStdio } from "node:child_process";
|
||||||
import {mkdir, readFile, readFileSync, rm, writeFile} from "node:fs";
|
import { mkdir, readFile, readFileSync, rm, writeFile } from "node:fs";
|
||||||
|
|
||||||
// reference: https://docs.deno.com/examples/hex_base64_encoding/
|
// reference: https://docs.deno.com/examples/hex_base64_encoding/
|
||||||
// import { decodeBase64, encodeBase64 } from "jsr:@std/encoding/base64";
|
// import { decodeBase64, encodeBase64 } from "jsr:@std/encoding/base64";
|
||||||
@@ -271,6 +271,30 @@ export function isEnvOn(envKey: string): boolean {
|
|||||||
return isOn(getEnv(envKey));
|
return isOn(getEnv(envKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function formatHumanTime2(timeMillis: number): string {
|
||||||
|
if (timeMillis < 1000) {
|
||||||
|
return `${timeMillis} ms`;
|
||||||
|
}
|
||||||
|
const timeSeconds = Math.floor(timeMillis / 1000);
|
||||||
|
if (timeSeconds < 60) {
|
||||||
|
return `${timeSeconds} seconds`;
|
||||||
|
}
|
||||||
|
const timeMinutes = Math.floor(timeSeconds / 60);
|
||||||
|
if (timeMinutes < 60) {
|
||||||
|
return `${timeMinutes} minutes`;
|
||||||
|
}
|
||||||
|
const timeHours = timeMinutes / 60;
|
||||||
|
if (timeHours < 24) {
|
||||||
|
return `${formatNumber(timeHours)} hours`;
|
||||||
|
}
|
||||||
|
const timeDays = timeHours / 24;
|
||||||
|
if (timeDays < 365) {
|
||||||
|
return `${formatNumber(timeDays)} days`;
|
||||||
|
}
|
||||||
|
const timeYears = timeDays / 365;
|
||||||
|
return `${formatNumber(timeYears)} years`;
|
||||||
|
}
|
||||||
|
|
||||||
export function formatHumanTime(timeMillis: number): string {
|
export function formatHumanTime(timeMillis: number): string {
|
||||||
const times = [];
|
const times = [];
|
||||||
if (timeMillis < 1000) {
|
if (timeMillis < 1000) {
|
||||||
|
|||||||
Reference in New Issue
Block a user