MCPcopy Create free account
hub / github.com/nodejs/node-addon-api / getExportObjectName

Function getExportObjectName

unit-test/listOfTestModules.js:14–22  ·  view source on GitHub ↗

* @param fileName - expect to be in snake case , eg: this_is_a_test_file.cc * @returns init function name in the file * * general format of init function name is camelCase version of the snake_case file name

(fileName)

Source from the content-addressed store, hash-verified

12 * general format of init function name is camelCase version of the snake_case file name
13 */
14function getExportObjectName (fileName) {
15 fileName = fileName.split('_').map(token => exceptions.nouns[token] ? exceptions.nouns[token] : token).join('_');
16 const str = fileName.replace(/(_\w)/g, (k) => k[1].toUpperCase());
17 const exportObjectName = str.charAt(0).toUpperCase() + str.substring(1);
18 if (exceptions.exportNames[exportObjectName]) {
19 return exceptions.exportNames[exportObjectName];
20 }
21 return exportObjectName;
22}
23
24/**
25 * @param fileName - expect to be in snake case , eg: this_is_a_test_file.cc

Callers 2

listOfTestModulesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected