scrabble-solver
Version:
Scrabble Solver 2 - Free, open-source, cross-platform, multi-language analysis tool for Scrabble, Scrabble Duel, Super Scrabble, Letter League, Crossplay, Literaki, and Kelimelik. Quickly find the top-scoring words using the given board and tiles.
26 lines (19 loc) • 642 B
text/typescript
import { type Trie } from '@kamilmielnik/trie';
import { type Locale } from '@scrabble-solver/types';
import type { Cache } from '../types';
export const createCacheTimestampComparator = (locale: Locale) => {
return (a: Cache<Locale, Trie>, b: Cache<Locale, Trie>): number => {
const aTimestamp = a.getLastModifiedTimestamp(locale);
const bTimestamp = b.getLastModifiedTimestamp(locale);
if (aTimestamp === bTimestamp) {
return 0;
}
if (typeof aTimestamp === 'undefined') {
return 1;
}
if (typeof bTimestamp === 'undefined') {
return -1;
}
return bTimestamp - aTimestamp;
};
};