UNPKG

btnexus-node

Version:
31 lines (28 loc) 852 B
/** * Language Captions class * @author Marc Fiedler * @copyright 2020 Blackout Technologies, all rights reserved */ // Use Strict mode ECMA Script 5+ "use_strict"; module.exports = class Captions { constructor(captionData){ this.data = captionData; } getCaption(language, key){ if( this.data[language] != undefined ){ if( this.data[language][key] != undefined ){ // LEGACY Support if( typeof this.data[language][key] == "string" ){ return this.data[language][key]; }else{ return this.data[language][key][Math.floor(Math.random() * this.data[language][key].length)]; } }else{ return undefined; } }else{ return undefined; } } }