MCPcopy Create free account
hub / github.com/WiseLibs/better-sqlite3 / wrapFactory

Function wrapFactory

lib/methods/table.js:23–39  ·  view source on GitHub ↗
(factory)

Source from the content-addressed store, hash-verified

21};
22
23function 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
41function parseTableDefinition(def, verb, moduleName) {
42 // Validate required properties

Callers 1

table.jsFile · 0.85

Calls 1

parseTableDefinitionFunction · 0.85

Tested by

no test coverage detected