UNPKG

smart-factory

Version:

functional programming-ready dependancy injector/ioc container library

40 lines 1.84 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const lib_1 = require("../lib"); var Modules; (function (Modules) { Modules["HELLO_FUNC"] = "HELLO_FUNC"; Modules["MSG_PROVIDER"] = "MSG_PROVIDER"; Modules["MSG_PRINTER"] = "MSG_PRINTER"; })(Modules = exports.Modules || (exports.Modules = {})); lib_1.injectable(Modules.MSG_PROVIDER, [], () => __awaiter(this, void 0, void 0, function* () { return (lang) => { if (lang === 'en') return 'HELLO!'; else if (lang === 'ko') return '안녕하세요!'; else if (lang === 'es') return 'HOLA!'; return 'UNKOWN LANGUAGE'; }; })); lib_1.injectable(Modules.MSG_PRINTER, [], () => __awaiter(this, void 0, void 0, function* () { return (msg) => console.log(msg); })); lib_1.injectable(Modules.HELLO_FUNC, [Modules.MSG_PROVIDER, Modules.MSG_PRINTER], (provider, printer) => __awaiter(this, void 0, void 0, function* () { return (lang) => { printer(provider(lang)); }; })); (() => __awaiter(this, void 0, void 0, function* () { yield lib_1.init(); const helloFunc = lib_1.resolve(Modules.HELLO_FUNC); helloFunc('es'); }))(); //# sourceMappingURL=index.js.map