All files / src/pairs mcoolName.ts

20% Statements 1/5
100% Branches 0/0
0% Functions 0/1
20% Lines 1/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16                    2x          
/**
 * What an `.mcool` written from an imported `.pairs` is called:
 * `Hum53.pairs.gz` → `Hum53.mcool`, the pairs file's own stem without the
 * `.pairs`, `.gz` (or `.bgz`) or `.px2` it came with.
 *
 * Its own module because two runtimes need it: the worker, which writes the
 * file, and the session, which has to ask where it goes *before* the worker
 * starts — a save dialog is opened from the press, and the press is long gone
 * by the time a whole ladder of resolutions has been written (`ui/export.ts`).
 */
export function mcoolNameFor(uri: string): string {
  const leaf = uri.split(/[\\/]/).pop() ?? 'pairs'
  const stem = leaf.replace(/\.px2$/i, '').replace(/\.b?gz$/i, '').replace(/\.pairs$/i, '')
  return `${stem || 'pairs'}.mcool`
}