word-vault
Version:
A lightweight JavaScript package for English word definitions and collections.
20 lines (19 loc) • 550 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPronunciationAudio = getPronunciationAudio;
const getPronunciation_1 = require("./getPronunciation");
function getPronunciationAudio({ id, region, pronunciation }) {
const pronunciationList = (0, getPronunciation_1.getPronunciation)({
id,
region,
});
if (!pronunciationList) {
return null;
}
if (!pronunciation) {
return pronunciationList?.[0]?.audio || null;
}
return (
pronunciationList.find((p) => p.pronunciation === pronunciation)?.audio ||
null
);
}