nixamp 0.12.0 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/enrich.d.ts CHANGED
@@ -73,8 +73,13 @@ export declare function whereToAsk(kind: EnrichKind, parsedKind?: string): {
73
73
  } | null;
74
74
  /** The key one name is remembered under: case and spacing do not make it a different name. */
75
75
  export declare function cacheKey(name: string, kind: EnrichKind, year: number | null): string;
76
- /** Whether a stored answer is still worth believing. */
77
- export declare function fresh(entry: Cached, now: number): boolean;
76
+ /**
77
+ * Whether a stored answer is still worth believing. A miss on a name that
78
+ * reads as a game is believed only as long as a score would be: the fixture
79
+ * may not be listed yet, and a channel named for tonight's game is asked
80
+ * about again while it plays, not six hours from now.
81
+ */
82
+ export declare function fresh(entry: Cached, now: number, matchup?: boolean): boolean;
78
83
  /** The best of nichedb's answers, or nothing when the best is a guess. */
79
84
  export declare function pickBest(answer: MatchAnswer, asked: string): Enriched | null;
80
85
  export interface EnricherOptions {
package/dist/enrich.js CHANGED
@@ -63,9 +63,20 @@ export function whereToAsk(kind, parsedKind) {
63
63
  export function cacheKey(name, kind, year) {
64
64
  return `${kind}|${year ?? ""}|${name.trim().toLowerCase().replace(/\s+/g, " ")}`;
65
65
  }
66
- /** Whether a stored answer is still worth believing. */
67
- export function fresh(entry, now) {
68
- const ttl = entry.hit === null ? MISS_TTL_MS : entry.hit.kind === "fixture" ? FIXTURE_TTL_MS : HIT_TTL_MS;
66
+ /**
67
+ * Whether a stored answer is still worth believing. A miss on a name that
68
+ * reads as a game is believed only as long as a score would be: the fixture
69
+ * may not be listed yet, and a channel named for tonight's game is asked
70
+ * about again while it plays, not six hours from now.
71
+ */
72
+ export function fresh(entry, now, matchup = false) {
73
+ const ttl = entry.hit === null
74
+ ? matchup
75
+ ? FIXTURE_TTL_MS
76
+ : MISS_TTL_MS
77
+ : entry.hit.kind === "fixture"
78
+ ? FIXTURE_TTL_MS
79
+ : HIT_TTL_MS;
69
80
  return now - entry.at < ttl;
70
81
  }
71
82
  /** The best of nichedb's answers, or nothing when the best is a guess. */
@@ -164,7 +175,7 @@ export class Enricher {
164
175
  return null;
165
176
  const key = cacheKey(asked, kind, year);
166
177
  const had = this.cache.get(key);
167
- if (had && fresh(had, this.now()))
178
+ if (had && fresh(had, this.now(), isMatchupName(asked)))
168
179
  return had.hit;
169
180
  const running = this.inflight.get(key);
170
181
  if (running)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nixamp",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "It really whips the terminal's ass. A Winamp-shaped audio player for your terminal.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/enrich.ts CHANGED
@@ -108,9 +108,21 @@ export function cacheKey(name: string, kind: EnrichKind, year: number | null): s
108
108
  return `${kind}|${year ?? ""}|${name.trim().toLowerCase().replace(/\s+/g, " ")}`;
109
109
  }
110
110
 
111
- /** Whether a stored answer is still worth believing. */
112
- export function fresh(entry: Cached, now: number): boolean {
113
- const ttl = entry.hit === null ? MISS_TTL_MS : entry.hit.kind === "fixture" ? FIXTURE_TTL_MS : HIT_TTL_MS;
111
+ /**
112
+ * Whether a stored answer is still worth believing. A miss on a name that
113
+ * reads as a game is believed only as long as a score would be: the fixture
114
+ * may not be listed yet, and a channel named for tonight's game is asked
115
+ * about again while it plays, not six hours from now.
116
+ */
117
+ export function fresh(entry: Cached, now: number, matchup = false): boolean {
118
+ const ttl =
119
+ entry.hit === null
120
+ ? matchup
121
+ ? FIXTURE_TTL_MS
122
+ : MISS_TTL_MS
123
+ : entry.hit.kind === "fixture"
124
+ ? FIXTURE_TTL_MS
125
+ : HIT_TTL_MS;
114
126
  return now - entry.at < ttl;
115
127
  }
116
128
 
@@ -214,7 +226,7 @@ export class Enricher {
214
226
  if (asked === "") return null;
215
227
  const key = cacheKey(asked, kind, year);
216
228
  const had = this.cache.get(key);
217
- if (had && fresh(had, this.now())) return had.hit;
229
+ if (had && fresh(had, this.now(), isMatchupName(asked))) return had.hit;
218
230
  const running = this.inflight.get(key);
219
231
  if (running) return running;
220
232
  const work = this.ask(asked, kind, year)
package/web/dist/sw.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /* nixamp service worker — generated, do not edit */
2
- const CACHE = "nixamp-1789052850004";
2
+ const CACHE = "nixamp-1789068526308";
3
3
  const PRECACHE = [
4
4
  "/",
5
5
  "/apple-touch-icon.png",