Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve, reject) => {
if (state.language.iso === LANGUAGE) return resolve(state);
const time = new Date();
Linguist.translate(state.rawSentence, state.language.iso || LANGUAGE, LANGUAGE, (response) => {
state.language = {
engine: 'yandex',
ms: (new Date() - time),
iso: response.lang,
};
state.sentence = response.text[0];
resolve(state);
});
})
}