word-vault
Version:
A lightweight JavaScript package for English word definitions and collections.
13 lines (12 loc) • 469 B
JavaScript
import { getCardPronunciation } from "./getCardPronunciation.js";
export async function getCardPronunciationAudio({ id, region, pronunciation, }) {
const pronunciationList = await getCardPronunciation({ id, region });
if (!pronunciationList) {
return null;
}
if (!pronunciation) {
return pronunciationList?.[0]?.audio || null;
}
return (pronunciationList.find((p) => p.pronunciation === pronunciation)?.audio ||
null);
}