refactor: Migrate project from Deno to pnpm/Node

Replace Deno configs and workflows with pnpm/Node tooling Add
package.json, jsr.json, build.config.ts and pnpm-lock.yaml Remove
deno.json, deno.lock, Deno build scripts and workflow Move source files
into src/ and update imports and tests to vitest Add Test CI workflow
and adapt publish jobs for pnpm/node Update editor settings, tasks,
.gitignore and bump LICENSE year
This commit is contained in:
Shibo Lyu 2025-11-29 19:11:49 +08:00
parent 7923680e80
commit 32534084df
26 changed files with 2132 additions and 430 deletions

View file

@ -1,43 +1,40 @@
import {
assertEquals,
assertThrows,
} from "https://deno.land/std@0.224.0/assert/mod.ts";
import { it, expect } from "vitest";
import { getCharacterWidth } from "../mod.ts";
import { getCharacterWidth } from "../src/mod.ts";
Deno.test("getCharacterWidth ASCII", () => {
assertEquals(getCharacterWidth("a"), 1);
assertEquals(getCharacterWidth("A"), 1);
assertEquals(getCharacterWidth("1"), 1);
assertEquals(getCharacterWidth("@"), 1);
assertEquals(getCharacterWidth(" "), 1);
it("getCharacterWidth ASCII", () => {
expect(getCharacterWidth("a")).toBe(1);
expect(getCharacterWidth("A")).toBe(1);
expect(getCharacterWidth("1")).toBe(1);
expect(getCharacterWidth("@")).toBe(1);
expect(getCharacterWidth(" ")).toBe(1);
assertThrows(() => getCharacterWidth(""));
assertThrows(() => getCharacterWidth("ab"));
expect(() => getCharacterWidth("")).toThrow();
expect(() => getCharacterWidth("ab")).toThrow();
});
Deno.test("getCharacterWidth CJK", () => {
assertEquals(getCharacterWidth("你"), 2);
assertEquals(getCharacterWidth("好"), 2);
assertEquals(getCharacterWidth("吗"), 2);
it("getCharacterWidth CJK", () => {
expect(getCharacterWidth("你")).toBe(2);
expect(getCharacterWidth("好")).toBe(2);
expect(getCharacterWidth("吗")).toBe(2);
assertEquals(getCharacterWidth("ガ"), 2);
assertEquals(getCharacterWidth("ギ"), 2);
assertEquals(getCharacterWidth("グ"), 2);
assertEquals(getCharacterWidth("ソ"), 2);
expect(getCharacterWidth("ガ")).toBe(2);
expect(getCharacterWidth("ギ")).toBe(2);
expect(getCharacterWidth("グ")).toBe(2);
expect(getCharacterWidth("ソ")).toBe(2);
assertEquals(getCharacterWidth(""), 2);
assertEquals(getCharacterWidth(""), 2);
assertThrows(() => getCharacterWidth("你好"));
assertThrows(() => getCharacterWidth("ヨスガノ"));
expect(getCharacterWidth("")).toBe(2);
expect(getCharacterWidth("")).toBe(2);
expect(() => getCharacterWidth("你好")).toThrow();
expect(() => getCharacterWidth("ヨスガノ")).toThrow();
});
Deno.test("getCharacterWidth Emoji", () => {
assertEquals(getCharacterWidth("👋"), 2);
assertEquals(getCharacterWidth("🌲️"), 2);
assertEquals(getCharacterWidth("👨‍👩‍👧‍👦"), 2);
it("getCharacterWidth Emoji", () => {
expect(getCharacterWidth("👋")).toBe(2);
expect(getCharacterWidth("🌲️")).toBe(2);
expect(getCharacterWidth("👨‍👩‍👧‍👦")).toBe(2);
});
Deno.test("getCharacterWidth previously faulty cases", () => {
assertEquals(getCharacterWidth("𤲶"), 2);
it("getCharacterWidth previously faulty cases", () => {
expect(getCharacterWidth("𤲶")).toBe(2);
});