feature: default sorts

This commit is contained in:
Andy Burke 2025-07-02 19:01:31 -07:00
parent 05178c924f
commit e32ee96b73
3 changed files with 93 additions and 5 deletions

18
fsdb.ts
View file

@ -427,4 +427,22 @@ export class FSDB_COLLECTION<T extends Record<string, any>> {
listener(event_data);
}
}
public sorts = {
newest: (a: WALK_ENTRY<T>, b: WALK_ENTRY<T>) =>
((b.info.birthtime ?? b.info.ctime)?.toISOString() ?? '').localeCompare(
(a.info.birthtime ?? a.info.ctime)?.toISOString() ?? ''
),
oldest: (a: WALK_ENTRY<T>, b: WALK_ENTRY<T>) =>
((a.info.birthtime ?? a.info.ctime)?.toISOString() ?? '').localeCompare(
(b.info.birthtime ?? b.info.ctime)?.toISOString() ?? ''
),
latest: (a: WALK_ENTRY<T>, b: WALK_ENTRY<T>) =>
((b.info.mtime ?? b.info.ctime)?.toISOString() ?? '').localeCompare((a.info.mtime ?? a.info.ctime)?.toISOString() ?? ''),
stalest: (a: WALK_ENTRY<T>, b: WALK_ENTRY<T>) =>
((a.info.mtime ?? a.info.ctime)?.toISOString() ?? '').localeCompare((b.info.mtime ?? b.info.ctime)?.toISOString() ?? '')
};
}