Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async init() {
log.debug('kuroshiro: initializing...')
if (!Prefs.get('kuroshiro')) {
log.debug('kuroshiro: disabled')
return
}
try {
this.kuroshiro = new Kuroshiro()
await this.kuroshiro.init(new KuromojiAnalyzer('resource://zotero-better-bibtex/kuromoji'))
} catch (err) {
log.error('kuroshiro: initializing failed')
throw err
}
log.debug('kuroshiro: ready')
this.enabled = true
}
public convert(str, options) {
if (!this.enabled) throw new Error('kuroshiro not initialized')
if (str && Kuroshiro.Util.hasJapanese(str)) return this.kuroshiro.convert(str, options)
return str
}
}