JavaScript-de eksportlar birikdirilende tutuş mazmuny import etmek

Eksportlar birikdirilende, esasy funksiýany we galan funksiýalary obyekt görnüşinde import etmek mümkin.

Geliň, munyň nädip edilýändigine seredeliň. Bizde aşakdaky eksportlar bar bolsun:

src/test.jsexport function func1() {
  return '1'
}
export function func2() {
  return '2'
}
export default function() {
  return 'text';
};

Esasy funksiýany we galan funksiýalary mod at bilen import edeliň:

src/index.jsimport test, * as mod from './test.js';

Esasy funksiýanyň işleýşini barlalyň:

src/index.jslet res = test();
console.log(res);

Galan funksiýalaryň işleýşini barlalyň:

src/index.jslet res1 = mod.func1();
let res2 = mod.func2();

console.log(res1, res2);
Задание 1

Bir esasy funksiýany we birnäçe goşmaça funksiýany funksiýalar obýekti görnüşinde eksport edýän modul düzüň.