get rid of sleep()

This commit is contained in:
MathMan05
2025-11-26 00:01:51 -06:00
parent 3d8450ff1a
commit 960752a685
3 changed files with 6 additions and 41 deletions
+6 -13
View File
@@ -15,12 +15,9 @@ export class KittyLogo {
public static async initialise() {
this.isSupported = await this.checkSupport();
if (this.isSupported)
this.iconCache = readFileSync(
__dirname + "/../../../assets/icon.png",
{
encoding: "base64",
},
);
this.iconCache = readFileSync(__dirname + "/../../../assets/icon.png", {
encoding: "base64",
});
}
public static printLogo(): void {
@@ -77,11 +74,9 @@ export class KittyLogo {
if (resp.startsWith("\x1B_Gi=31;OK")) resolve(true);
else resolve(false);
});
process.stdout.write(
"\x1b_Gi=31,s=1,v=1,a=q,t=d,f=24;AAAA\x1b\\\x1b[c",
);
process.stdout.write("\x1b_Gi=31,s=1,v=1,a=q,t=d,f=24;AAAA\x1b\\\x1b[c");
await sleep(5000);
await new Promise((res) => setTimeout(res, 5000));
resolve(false);
})();
});
@@ -111,9 +106,7 @@ export class KittyLogo {
while (pngData.length > 0) {
const dataSize = Math.min(pngData.length, chunkSize);
process.stdout.write(
header + `,m=${dataSize == chunkSize ? 1 : 0};`,
);
process.stdout.write(header + `,m=${dataSize == chunkSize ? 1 : 0};`);
process.stdout.write(pngData.slice(0, chunkSize));
pngData = pngData.slice(chunkSize);
process.stdout.write("\x1b\\");
-16
View File
@@ -1,16 +0,0 @@
import moduleAlias from "module-alias";
moduleAlias();
import './Global';
import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
describe("Global extensions", () => {
it("sleep", async () => {
const start = Date.now();
await sleep(100);
const duration = Date.now() - start;
assert(duration >= 100, `Sleep duration was less than expected: ${duration}ms`);
});
});
-12
View File
@@ -1,12 +0,0 @@
declare global {
function sleep(ms: number): Promise<void>;
}
export function globalSleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}
if (!globalThis.sleep)
globalThis.sleep = function (ms: number): Promise<void> {
return globalSleep(ms);
};