From a6902a5fba868cbb53aa680899433e3185a7340b Mon Sep 17 00:00:00 2001 From: Mopsgamer <79159094+Mopsgamer@users.noreply.github.com> Date: Sat, 13 Dec 2025 23:05:37 +0100 Subject: [PATCH 1/8] test: add sort edge case --- sort.test.ts | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/sort.test.ts b/sort.test.ts index 98d19a9..f414043 100644 --- a/sort.test.ts +++ b/sort.test.ts @@ -19,30 +19,24 @@ Deno.test("sort.isSortName - true/false", () => { }); Deno.test("mixed comparator orders strings", () => { - const a = sort.cmpMixed("a", "b"); - const b = sort.cmpMixed("b", "a"); - assertLess(a, 0); - assertGreater(b, 0); + assertLess(sort.cmpMixed("a", "b"), 0); + assertGreater(sort.cmpMixed("b", "a"), 0); assertEquals(sort.cmpMixed("same", "same"), 0); }); Deno.test("type comparator groups by extension then name", () => { - const cmp = sort.cmpFileType("file.md", "file.txt"); - assertLess(cmp, 0); - const cmp2 = sort.cmpFileType("a.txt", "b.txt"); - assertLess(cmp2, 0); + assertLess(sort.cmpFileType("file.md", "file.txt"), 0); + assertLess(sort.cmpFileType("a.txt", "b.txt"), 0); }); Deno.test("sort.cmpFirstFolders puts folders before files", () => { - const arr = ["dir", "dir/file"]; - arr.sort(sort.cmpFirstFolders); - assertEquals(arr, ["dir/file", "dir"]); + assertEquals(["dir", "dir/file"].sort(sort.cmpFirstFolders), ["dir/file", "dir"]); + assertEquals(["src/targets/yarn.ts", "src/...+16"].sort(sort.cmpFirstFolders), ["src/...+16", "src/targets/yarn.ts"]); }); Deno.test("sort.cmpFirstFiles puts files before folders", () => { - const arr = ["dir", "dir/file"]; - arr.sort(sort.cmpFirstFiles); - assertEquals(arr, ["dir", "dir/file"]); + assertEquals(["dir", "dir/file"].sort(sort.cmpFirstFiles), ["dir", "dir/file"]); + assertEquals(["src/targets/yarn.ts", "src/...+16"].sort(sort.cmpFirstFiles), ["src/...+16", "src/targets/yarn.ts"]); }); Deno.test("sort.isSortName - non-string returns false", () => { @@ -109,27 +103,19 @@ Deno.test("sort.cmpFirstFolders/sort.cmpFirstFiles equal names return 0", () => }); Deno.test("sort-iterable: sortFirstFolders basic", () => { - const input = ["dir", "dir/file"]; - const out = sort.sortFirstFolders(input); - assertEquals(out, ["dir/file", "dir"]); + assertEquals(sort.sortFirstFolders(["dir", "dir/file"]), ["dir/file", "dir"]); }); Deno.test("sort-iterable: sortsort.cmpFirstFiles basic", () => { - const input = ["dir", "dir/file"]; - const out = sort.sortFirstFiles(input); - assertEquals(out, ["dir", "dir/file"]); + assertEquals(sort.sortFirstFiles(["dir", "dir/file"]), ["dir", "dir/file"]); }); Deno.test("sort-iterable: sortFileType basic", () => { - const input = ["a.txt", "b.md", "a.md"]; - const out = sort.sortFileType(input); - assertEquals(out, ["a.md", "b.md", "a.txt"]); + assertEquals(sort.sortFileType(["a.txt", "b.md", "a.md"]), ["a.md", "b.md", "a.txt"]); }); Deno.test("sort-iterable: sortMixed basic", () => { - const input = ["b", "a", "c"]; - const out = sort.sortMixed(input); - assertEquals(out, ["a", "b", "c"]); + assertEquals(sort.sortMixed(["b", "a", "c"]), ["a", "b", "c"]); }); Deno.test("sort-iterable: sortModified basic", () => { From 721637e5f9126daeea5acf6c0fe752d3d733b9aa Mon Sep 17 00:00:00 2001 From: github-actions Date: Sat, 13 Dec 2025 22:07:23 +0000 Subject: [PATCH 2/8] style: code formatting --- sort.test.ts | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/sort.test.ts b/sort.test.ts index f414043..37fb7e5 100644 --- a/sort.test.ts +++ b/sort.test.ts @@ -30,13 +30,25 @@ Deno.test("type comparator groups by extension then name", () => { }); Deno.test("sort.cmpFirstFolders puts folders before files", () => { - assertEquals(["dir", "dir/file"].sort(sort.cmpFirstFolders), ["dir/file", "dir"]); - assertEquals(["src/targets/yarn.ts", "src/...+16"].sort(sort.cmpFirstFolders), ["src/...+16", "src/targets/yarn.ts"]); + assertEquals(["dir", "dir/file"].sort(sort.cmpFirstFolders), [ + "dir/file", + "dir", + ]); + assertEquals( + ["src/targets/yarn.ts", "src/...+16"].sort(sort.cmpFirstFolders), + ["src/...+16", "src/targets/yarn.ts"], + ); }); Deno.test("sort.cmpFirstFiles puts files before folders", () => { - assertEquals(["dir", "dir/file"].sort(sort.cmpFirstFiles), ["dir", "dir/file"]); - assertEquals(["src/targets/yarn.ts", "src/...+16"].sort(sort.cmpFirstFiles), ["src/...+16", "src/targets/yarn.ts"]); + assertEquals(["dir", "dir/file"].sort(sort.cmpFirstFiles), [ + "dir", + "dir/file", + ]); + assertEquals(["src/targets/yarn.ts", "src/...+16"].sort(sort.cmpFirstFiles), [ + "src/...+16", + "src/targets/yarn.ts", + ]); }); Deno.test("sort.isSortName - non-string returns false", () => { @@ -111,7 +123,11 @@ Deno.test("sort-iterable: sortsort.cmpFirstFiles basic", () => { }); Deno.test("sort-iterable: sortFileType basic", () => { - assertEquals(sort.sortFileType(["a.txt", "b.md", "a.md"]), ["a.md", "b.md", "a.txt"]); + assertEquals(sort.sortFileType(["a.txt", "b.md", "a.md"]), [ + "a.md", + "b.md", + "a.txt", + ]); }); Deno.test("sort-iterable: sortMixed basic", () => { From 4972f1c681f03a85ebf1894ac5e277fd475b6cc7 Mon Sep 17 00:00:00 2001 From: Mopsgamer <79159094+Mopsgamer@users.noreply.github.com> Date: Sun, 14 Dec 2025 11:23:32 +0100 Subject: [PATCH 3/8] ci: no auto format --- .github/workflows/format.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 5b601de..e45000d 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -17,15 +17,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - with: - ref: ${{ github.head_ref }} - token: ${{ secrets.GITHUB_TOKEN }} - repository: ${{ github.repository }} - - name: Set Git origin - run: | - git config --global user.name "github-actions" - git config --global user.email "github-actions@github.com" - git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} - uses: denoland/setup-deno@v2 with: deno-version: v2.x @@ -35,8 +26,3 @@ jobs: deno install --allow-scripts deno lint --fix deno fmt - - name: Push formatting changes (if any) - run: | - git diff --quiet || ( - git commit -a -m "style: code formatting" && - git push) From df8bf9b0a40e7a495cd653e15fc783087b123400 Mon Sep 17 00:00:00 2001 From: Mopsgamer <79159094+Mopsgamer@users.noreply.github.com> Date: Sun, 14 Dec 2025 11:25:08 +0100 Subject: [PATCH 4/8] fix: cmpModified style: shift and funcs --- convert.ts | 5 ++-- shift.ts | 19 ++++++++++-- sort-cmp.ts | 81 ++++++++++++++++++++++++---------------------------- sort.test.ts | 18 ++++++------ 4 files changed, 65 insertions(+), 58 deletions(-) diff --git a/convert.ts b/convert.ts index 0a481fb..6f9a1fa 100644 --- a/convert.ts +++ b/convert.ts @@ -132,7 +132,7 @@ export function pathObjectFrom( let root: PathRecord = {}; for (const element of iterable) { - let [next, other, isLast] = shiftPath(element); + let {next, other, isLast} = shiftPath(element); let parent: PathRecord = root; if (isLast) { @@ -145,7 +145,8 @@ export function pathObjectFrom( while (!isLast || (parent[next] = "")) { parent = child as { [key: string]: PathRecord }; - [next, other, isLast] = shiftPath(other); + const {next: nextNew, other: otherNew, isLast: isLastNew} = shiftPath(other); + [next, other, isLast] = [nextNew, otherNew, isLastNew]; child = parent[next] ?? {}; parent[next] = child; } diff --git a/shift.ts b/shift.ts index 3e14f57..1c58737 100644 --- a/shift.ts +++ b/shift.ts @@ -1,3 +1,9 @@ +export type ShiftResult = { + next: string; + other: string; + isLast: boolean; +}; + /** * @example * "path/to/the/file" -> ["path", "to/the/file", false] @@ -6,10 +12,17 @@ */ export function shiftPath( p: string, -): [next: string, other: string, isLast: boolean] { +): ShiftResult { const slashIndex = p.search(/[/\\]/); const next = p.slice(0, Math.max(0, slashIndex)); const other = p.slice(Math.max(0, slashIndex + 1)); - const isLast = next === ""; - return [slashIndex < 0 ? other : next, other, isLast]; + const r: ShiftResult = { + next: next, + other: other, + isLast: next == "", + }; + if (slashIndex < 0) { + r.next = r.other; + } + return r; } diff --git a/sort-cmp.ts b/sort-cmp.ts index ff941f8..f416067 100644 --- a/sort-cmp.ts +++ b/sort-cmp.ts @@ -45,22 +45,19 @@ export function isSortName(value: unknown): value is SortName { * Folders are displayed before files. */ export function cmpFirstFolders(a: string, b: string): number { + if (a === b) return 0; + let comp = 0; - for (; comp === 0;) { - const [next1, post1, last1] = shiftPath(a); + while (comp === 0) { + const { next: next1, other: post1, isLast: last1 } = shiftPath(a); a = post1; - const [next2, post2, last2] = shiftPath(b); + const { next: next2, other: post2, isLast: last2 } = shiftPath(b); b = post2; + comp = cmpMixed(next1, next2); if (last1 || last2) { - if (last1 === last2) { - break; - } - - if (!last1) { - return -1; - } - + if (last1 === last2) break; + if (!last1) return -1; return +1; } } @@ -73,22 +70,18 @@ export function cmpFirstFolders(a: string, b: string): number { * Files are displayed before folders. */ export function cmpFirstFiles(a: string, b: string): number { + if (a === b) return 0; + let comp = 0; - for (; comp === 0;) { - const [next1, post1, last1] = shiftPath(a); + while (comp === 0) { + const { next: next1, other: post1, isLast: last1 } = shiftPath(a); a = post1; - const [next2, post2, last2] = shiftPath(b); + const { next: next2, other: post2, isLast: last2 } = shiftPath(b); b = post2; comp = cmpMixed(next1, next2); if (last1 || last2) { - if (last1 === last2) { - break; - } - - if (last1) { - return -1; - } - + if (last1 === last2) break; + if (last1) return -1; return +1; } } @@ -106,22 +99,24 @@ export function cmpModified( timea: number = 0, timeb: number = 0, ): number { - if (a === b) { - return 0; - } + if (a === b) return 0; - while (true) { - const [next1, post1, last1] = shiftPath(a); + let comp = 0; + while (comp === 0) { + const { next: next1, other: post1, isLast: last1 } = shiftPath(a); a = post1; - const [next2, post2, last2] = shiftPath(b); + const { next: next2, other: post2, isLast: last2 } = shiftPath(b); b = post2; - let comp = (timeb - timea) || cmpFirstFolders(next1, next2); - if (comp) return comp; - - if (last1) return +1; - if (last2) return -1; + comp = (timeb - timea) || cmpFirstFolders(next1, next2); + if (last1 || last2) { + if (last1 === last2) break; + if (!last1) return -1; + return +1; + } } + + return comp; } /** @@ -129,24 +124,21 @@ export function cmpModified( * Folders are displayed before files. */ export function cmpFileType(a: string, b: string): number { + if (a === b) return 0; + let comp = 0; - for (; comp === 0;) { - const [next1, post1, last1] = shiftPath(a); + while (comp === 0) { + const { next: next1, other: post1, isLast: last1 } = shiftPath(a); a = post1; - const [next2, post2, last2] = shiftPath(b); + const { next: next2, other: post2, isLast: last2 } = shiftPath(b); b = post2; + const ppa = path.parse(next1); const ppb = path.parse(next2); comp = cmpMixed(ppa.ext, ppb.ext) || cmpMixed(ppa.name, ppb.name); if (last1 || last2) { - if (last1 === last2) { - break; - } - - if (!last1) { - return -1; - } - + if (last1 === last2) break; + if (!last1) return -1; return +1; } } @@ -159,5 +151,6 @@ export function cmpFileType(a: string, b: string): number { * Files are interwoven with folders. */ export function cmpMixed(a: string, b: string): number { + if (a === b) return 0; return a.localeCompare(b, undefined, { ignorePunctuation: false }); } diff --git a/sort.test.ts b/sort.test.ts index 37fb7e5..d17445a 100644 --- a/sort.test.ts +++ b/sort.test.ts @@ -8,9 +8,9 @@ import * as sort from "./sort.ts"; import { shiftPath } from "./shift.ts"; Deno.test("shiftPath - examples", () => { - assertEquals(shiftPath("path/to/the/file"), ["path", "to/the/file", false]); - assertEquals(shiftPath("file"), ["file", "file", true]); - assertEquals(shiftPath("file/"), ["file", "", false]); + assertEquals(shiftPath("path/to/the/file"), {next: "path", other:"to/the/file", isLast:false}); + assertEquals(shiftPath("file"), {next: "file", other:"file", isLast:true}); + assertEquals(shiftPath("file/"), {next: "file", other:"", isLast:false}); }); Deno.test("sort.isSortName - true/false", () => { @@ -84,14 +84,14 @@ Deno.test("modified comparator", () => { assertLess(sort.cmpModified("a/file1", "a/file2", 200, 200), 0); // Folder with same modified date as file - assertGreater(sort.cmpModified("a/fzlder/b", "a/file", 200, 200), 0); - assertGreater(sort.cmpModified("a/fzlder/b/c", "a/file", 200, 200), 0); - assertGreater(sort.cmpModified("a/fzlder/b/c/d", "a/file", 200, 200), 0); + assertLess(sort.cmpModified("a/fzlder/b", "a/file", 200, 200), 0); + assertLess(sort.cmpModified("a/fzlder/b/c", "a/file", 200, 200), 0); + assertLess(sort.cmpModified("a/fzlder/b/c/d", "a/file", 200, 200), 0); assertLess(sort.cmpModified("a/file/b", "a/file", 200, 200), 0); - assertLess(sort.cmpModified("a/file", "a/fzlder/b", 200, 200), 0); - assertLess(sort.cmpModified("a/file", "a/fzlder/b/c", 200, 200), 0); - assertLess(sort.cmpModified("a/file", "a/fzlder/b/c/d", 200, 200), 0); + assertGreater(sort.cmpModified("a/file", "a/fzlder/b", 200, 200), 0); + assertGreater(sort.cmpModified("a/file", "a/fzlder/b/c", 200, 200), 0); + assertGreater(sort.cmpModified("a/file", "a/fzlder/b/c/d", 200, 200), 0); assertGreater(sort.cmpModified("a/file", "a/file/b", 200, 200), 0); }); From a1a0279a584cfee72343679272ba09587367d29b Mon Sep 17 00:00:00 2001 From: Mopsgamer <79159094+Mopsgamer@users.noreply.github.com> Date: Sun, 14 Dec 2025 12:15:39 +0100 Subject: [PATCH 5/8] fix: fixup --- convert.ts | 8 ++++++-- sort-cmp.ts | 50 +++++++++++++++++++++++--------------------------- sort.test.ts | 22 +++++++++++++++------- 3 files changed, 44 insertions(+), 36 deletions(-) diff --git a/convert.ts b/convert.ts index 6f9a1fa..41b7bb5 100644 --- a/convert.ts +++ b/convert.ts @@ -132,7 +132,7 @@ export function pathObjectFrom( let root: PathRecord = {}; for (const element of iterable) { - let {next, other, isLast} = shiftPath(element); + let { next, other, isLast } = shiftPath(element); let parent: PathRecord = root; if (isLast) { @@ -145,7 +145,11 @@ export function pathObjectFrom( while (!isLast || (parent[next] = "")) { parent = child as { [key: string]: PathRecord }; - const {next: nextNew, other: otherNew, isLast: isLastNew} = shiftPath(other); + const { + next: nextNew, + other: otherNew, + isLast: isLastNew, + } = shiftPath(other); [next, other, isLast] = [nextNew, otherNew, isLastNew]; child = parent[next] ?? {}; parent[next] = child; diff --git a/sort-cmp.ts b/sort-cmp.ts index f416067..c599150 100644 --- a/sort-cmp.ts +++ b/sort-cmp.ts @@ -46,7 +46,6 @@ export function isSortName(value: unknown): value is SortName { */ export function cmpFirstFolders(a: string, b: string): number { if (a === b) return 0; - let comp = 0; while (comp === 0) { const { next: next1, other: post1, isLast: last1 } = shiftPath(a); @@ -55,11 +54,11 @@ export function cmpFirstFolders(a: string, b: string): number { b = post2; comp = cmpMixed(next1, next2); - if (last1 || last2) { - if (last1 === last2) break; - if (!last1) return -1; - return +1; - } + + if (!last1 && !last2) continue; + if (last1 && last2) break; + if (!last1) return -1; + return +1; } return comp; @@ -71,19 +70,19 @@ export function cmpFirstFolders(a: string, b: string): number { */ export function cmpFirstFiles(a: string, b: string): number { if (a === b) return 0; - let comp = 0; while (comp === 0) { const { next: next1, other: post1, isLast: last1 } = shiftPath(a); a = post1; const { next: next2, other: post2, isLast: last2 } = shiftPath(b); b = post2; + comp = cmpMixed(next1, next2); - if (last1 || last2) { - if (last1 === last2) break; - if (last1) return -1; - return +1; - } + + if (!last1 && !last2) continue; + if (last1 && last2) break; + if (last1) return -1; + return +1; } return comp; @@ -99,8 +98,6 @@ export function cmpModified( timea: number = 0, timeb: number = 0, ): number { - if (a === b) return 0; - let comp = 0; while (comp === 0) { const { next: next1, other: post1, isLast: last1 } = shiftPath(a); @@ -108,15 +105,15 @@ export function cmpModified( const { next: next2, other: post2, isLast: last2 } = shiftPath(b); b = post2; - comp = (timeb - timea) || cmpFirstFolders(next1, next2); - if (last1 || last2) { - if (last1 === last2) break; - if (!last1) return -1; - return +1; - } + comp = timeb - timea || cmpMixed(next1, next2); + + if (!last1 && !last2) continue; + if (last1 && last2) break; + if (!last1) return -1; + return +1; } - return comp; + return comp || cmpFirstFolders(a, b); } /** @@ -125,7 +122,6 @@ export function cmpModified( */ export function cmpFileType(a: string, b: string): number { if (a === b) return 0; - let comp = 0; while (comp === 0) { const { next: next1, other: post1, isLast: last1 } = shiftPath(a); @@ -136,11 +132,11 @@ export function cmpFileType(a: string, b: string): number { const ppa = path.parse(next1); const ppb = path.parse(next2); comp = cmpMixed(ppa.ext, ppb.ext) || cmpMixed(ppa.name, ppb.name); - if (last1 || last2) { - if (last1 === last2) break; - if (!last1) return -1; - return +1; - } + + if (!last1 && !last2) continue; + if (last1 && last2) break; + if (!last1) return -1; + return +1; } return comp; diff --git a/sort.test.ts b/sort.test.ts index d17445a..3ef3a90 100644 --- a/sort.test.ts +++ b/sort.test.ts @@ -8,9 +8,17 @@ import * as sort from "./sort.ts"; import { shiftPath } from "./shift.ts"; Deno.test("shiftPath - examples", () => { - assertEquals(shiftPath("path/to/the/file"), {next: "path", other:"to/the/file", isLast:false}); - assertEquals(shiftPath("file"), {next: "file", other:"file", isLast:true}); - assertEquals(shiftPath("file/"), {next: "file", other:"", isLast:false}); + assertEquals(shiftPath("path/to/the/file"), { + next: "path", + other: "to/the/file", + isLast: false, + }); + assertEquals(shiftPath("file"), { + next: "file", + other: "file", + isLast: true, + }); + assertEquals(shiftPath("file/"), { next: "file", other: "", isLast: false }); }); Deno.test("sort.isSortName - true/false", () => { @@ -123,10 +131,10 @@ Deno.test("sort-iterable: sortsort.cmpFirstFiles basic", () => { }); Deno.test("sort-iterable: sortFileType basic", () => { - assertEquals(sort.sortFileType(["a.txt", "b.md", "a.md"]), [ - "a.md", - "b.md", - "a.txt", + assertEquals(sort.sortFileType(["a.a", "b.a", "a.b"]), [ + "a.a", + "b.a", + "a.b", ]); }); From c7421ba996b372b5dab4f8ca9bf747bfd0d5d14b Mon Sep 17 00:00:00 2001 From: Mopsgamer <79159094+Mopsgamer@users.noreply.github.com> Date: Sun, 14 Dec 2025 12:29:49 +0100 Subject: [PATCH 6/8] fix: the thing --- sort-cmp.ts | 4 ++++ sort.test.ts | 16 ++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/sort-cmp.ts b/sort-cmp.ts index c599150..be3271c 100644 --- a/sort-cmp.ts +++ b/sort-cmp.ts @@ -55,6 +55,7 @@ export function cmpFirstFolders(a: string, b: string): number { comp = cmpMixed(next1, next2); + if (comp) break if (!last1 && !last2) continue; if (last1 && last2) break; if (!last1) return -1; @@ -79,6 +80,7 @@ export function cmpFirstFiles(a: string, b: string): number { comp = cmpMixed(next1, next2); + if (comp) break if (!last1 && !last2) continue; if (last1 && last2) break; if (last1) return -1; @@ -107,6 +109,7 @@ export function cmpModified( comp = timeb - timea || cmpMixed(next1, next2); + if (comp) break if (!last1 && !last2) continue; if (last1 && last2) break; if (!last1) return -1; @@ -133,6 +136,7 @@ export function cmpFileType(a: string, b: string): number { const ppb = path.parse(next2); comp = cmpMixed(ppa.ext, ppb.ext) || cmpMixed(ppa.name, ppb.name); + if (comp) break if (!last1 && !last2) continue; if (last1 && last2) break; if (!last1) return -1; diff --git a/sort.test.ts b/sort.test.ts index 3ef3a90..e755aea 100644 --- a/sort.test.ts +++ b/sort.test.ts @@ -81,8 +81,8 @@ Deno.test("modified comparator", () => { assertGreater(sort.cmpModified("a/file", "b/file", 100, 200), 0); // File vs folder (folders first) - assertLess(sort.cmpModified("a/file", "a/folder", 200, 100), 1); - assertGreater(sort.cmpModified("a/folder", "a/file", 100, 200), -1); + assertLess(sort.cmpModified("a/file", "a/folder", 200, 100), 0); + assertGreater(sort.cmpModified("a/folder", "a/file", 100, 200), 0); // Folder vs folder, different dates assertLess(sort.cmpModified("a/folder1", "a/folder2", 200, 100), 0); @@ -92,14 +92,14 @@ Deno.test("modified comparator", () => { assertLess(sort.cmpModified("a/file1", "a/file2", 200, 200), 0); // Folder with same modified date as file - assertLess(sort.cmpModified("a/fzlder/b", "a/file", 200, 200), 0); - assertLess(sort.cmpModified("a/fzlder/b/c", "a/file", 200, 200), 0); - assertLess(sort.cmpModified("a/fzlder/b/c/d", "a/file", 200, 200), 0); + assertGreater(sort.cmpModified("a/fzlder/b", "a/file", 200, 200), 0); + assertGreater(sort.cmpModified("a/fzlder/b/c", "a/file", 200, 200), 0); + assertGreater(sort.cmpModified("a/fzlder/b/c/d", "a/file", 200, 200), 0); assertLess(sort.cmpModified("a/file/b", "a/file", 200, 200), 0); - assertGreater(sort.cmpModified("a/file", "a/fzlder/b", 200, 200), 0); - assertGreater(sort.cmpModified("a/file", "a/fzlder/b/c", 200, 200), 0); - assertGreater(sort.cmpModified("a/file", "a/fzlder/b/c/d", 200, 200), 0); + assertLess(sort.cmpModified("a/file", "a/fzlder/b", 200, 200), 0); + assertLess(sort.cmpModified("a/file", "a/fzlder/b/c", 200, 200), 0); + assertLess(sort.cmpModified("a/file", "a/fzlder/b/c/d", 200, 200), 0); assertGreater(sort.cmpModified("a/file", "a/file/b", 200, 200), 0); }); From 1cfbd526c4ef8a9b16878c795ce3eb950958bb7b Mon Sep 17 00:00:00 2001 From: Mopsgamer <79159094+Mopsgamer@users.noreply.github.com> Date: Sun, 14 Dec 2025 12:33:40 +0100 Subject: [PATCH 7/8] ci: fmt --check --- .github/workflows/format.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index e45000d..da9d3fa 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -25,4 +25,4 @@ jobs: run: | deno install --allow-scripts deno lint --fix - deno fmt + deno fmt --check From a26c1031f0953c06e5e5d4723d7ed41d1f5cb25b Mon Sep 17 00:00:00 2001 From: Mopsgamer <79159094+Mopsgamer@users.noreply.github.com> Date: Sun, 14 Dec 2025 12:33:57 +0100 Subject: [PATCH 8/8] style: format --- sort-cmp.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sort-cmp.ts b/sort-cmp.ts index be3271c..a0450b2 100644 --- a/sort-cmp.ts +++ b/sort-cmp.ts @@ -55,7 +55,7 @@ export function cmpFirstFolders(a: string, b: string): number { comp = cmpMixed(next1, next2); - if (comp) break + if (comp) break; if (!last1 && !last2) continue; if (last1 && last2) break; if (!last1) return -1; @@ -80,7 +80,7 @@ export function cmpFirstFiles(a: string, b: string): number { comp = cmpMixed(next1, next2); - if (comp) break + if (comp) break; if (!last1 && !last2) continue; if (last1 && last2) break; if (last1) return -1; @@ -109,7 +109,7 @@ export function cmpModified( comp = timeb - timea || cmpMixed(next1, next2); - if (comp) break + if (comp) break; if (!last1 && !last2) continue; if (last1 && last2) break; if (!last1) return -1; @@ -136,7 +136,7 @@ export function cmpFileType(a: string, b: string): number { const ppb = path.parse(next2); comp = cmpMixed(ppa.ext, ppb.ext) || cmpMixed(ppa.name, ppb.name); - if (comp) break + if (comp) break; if (!last1 && !last2) continue; if (last1 && last2) break; if (!last1) return -1;