UNPKG

627 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3/**
4 * Convert a factory function with no arguments or a class with a no arg
5 * constructor to a factory function
6 * @param {Maker<T>} fact
7 * @return {Factory<T>}
8 */
9function toFactory(fact) {
10 const detyped = fact;
11 try {
12 const chf = () => new detyped();
13 // Try it to see if it works
14 chf();
15 return chf;
16 }
17 catch (e) {
18 // If we didn't succeed in using the constructor, try the other way
19 return detyped;
20 }
21}
22exports.toFactory = toFactory;
23//# sourceMappingURL=constructionUtils.js.map
\No newline at end of file