all files / lib/ exporter.js

90.91% Statements 10/11
75% Branches 3/4
100% Functions 5/5
90.91% Lines 10/11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26              18× 18×   18×                
import { each, uniq } from 'lodash';
 
export default (requests, lang) => {
  const result = [];
 
  each(requests, response => {
    Iif (response.type !== 'dictionary' || response.fromLang !== lang) {
      return;
    }
 
    response.result.forEach(entry => {
      entry.translations.forEach(translation => {
        translation.examples.forEach(example => {
          const origin = example.text;
          const translation = example.translations[0];
 
          result.push(translation + "\t" + origin);
        });
      });
    });
 
  });
 
  return uniq(result);
};