(factory)
| 21 | }; |
| 22 | |
| 23 | function wrapFactory(factory) { |
| 24 | return function virtualTableFactory(moduleName, databaseName, tableName, ...args) { |
| 25 | const thisObject = { |
| 26 | module: moduleName, |
| 27 | database: databaseName, |
| 28 | table: tableName, |
| 29 | }; |
| 30 | |
| 31 | // Generate a new table definition by invoking the factory |
| 32 | const def = apply.call(factory, thisObject, args); |
| 33 | if (typeof def !== 'object' || def === null) { |
| 34 | throw new TypeError(`Virtual table module "${moduleName}" did not return a table definition object`); |
| 35 | } |
| 36 | |
| 37 | return parseTableDefinition(def, 'returned', moduleName); |
| 38 | }; |
| 39 | } |
| 40 | |
| 41 | function parseTableDefinition(def, verb, moduleName) { |
| 42 | // Validate required properties |
no test coverage detected