feature: default sorts
This commit is contained in:
parent
05178c924f
commit
e32ee96b73
3 changed files with 93 additions and 5 deletions
18
fsdb.ts
18
fsdb.ts
|
@ -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() ?? '')
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue