2020-03-18 19:58:12 +00:00
|
|
|
import {parseDictionary} from './parsing-dictionary';
|
2020-03-19 18:12:06 +00:00
|
|
|
import getAudio from '../api/word-sound';
|
|
|
|
import {compoundWithYDictionary} from './get-translate';
|
2020-03-18 19:58:12 +00:00
|
|
|
|
2020-03-19 20:04:57 +00:00
|
|
|
export const createDictionary = async apiRes => {
|
2020-03-19 18:12:06 +00:00
|
|
|
const word = apiRes.word;
|
2020-03-18 19:58:12 +00:00
|
|
|
const parsedDictionary = parseDictionary(apiRes);
|
2020-03-20 15:19:09 +00:00
|
|
|
const audio = await getAudio(word);
|
2020-03-28 06:28:54 +00:00
|
|
|
|
2020-03-20 15:19:09 +00:00
|
|
|
const compounded = await compoundWithYDictionary(parsedDictionary, word);
|
2020-03-28 06:28:54 +00:00
|
|
|
//TODO add shrinkToOneExample(compounded)
|
2020-04-03 05:14:18 +00:00
|
|
|
return {...compounded, sound: audio, examples: parsedDictionary.examples};
|
2020-03-18 19:58:12 +00:00
|
|
|
};
|