Skip to content

Commit

Permalink
Use template literal vs JSON.stringify for keygen
Browse files Browse the repository at this point in the history
  • Loading branch information
John Schulz committed Aug 27, 2020
1 parent a3c303f commit e5c0e92
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ export const cacheSet = (key: string, value: Buffer) => cache.set(key, value);
export const cacheHas = (key: string) => cache.has(key);

const archiveKeyCache: Map<string, string> = new Map();
const stableKey = JSON.stringify;
const stableKey = ({ name, version }: { name: string; version: string }) => `${name}-${version}`;

export const getArchiveKey = (name: string, version: string) =>
archiveKeyCache.get(stableKey({ name, version }));

export const setArchiveKey = (name: string, version: string, location: string) =>
archiveKeyCache.set(stableKey({ name, version }), location);

0 comments on commit e5c0e92

Please sign in to comment.