/
githubmirror
/
webpack
Обзор
Документация
Войти
/
githubmirror
/
webpack
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
test/cases/inner-graph/switch/module.js
41 строка
769 B
Tobias Koppers
add more test cases
01 окт 2019, 10:53
01 окт 2019, 10:53
c47e1f8
Код
Авторство
О чём код?
import { Block, Inline, Document } from "./some-module"; function getType(obj) { return obj.type; } // Local functions function doSomethingWithBlock(obj) { return Block.doSomething(obj); } function doSomethingWithInline(obj) { return Inline.doSomething(obj); } function doSomethingWithDocument(obj) { return Document.doSomething(obj); } // Exported functions function doSomething(obj) { const type = getType(obj); switch (type) { case "document": return doSomethingWithDocument(obj); case "block": return doSomethingWithBlock(obj); case "inline": return doSomethingWithInline(obj); default: throw new Error(); } } function useDocument(obj) { return doSomethingWithDocument(obj); } export { useDocument }; export default doSomething;