MCPcopy Create free account
hub / github.com/charto/nbind / initAsm

Function initAsm

src/nbind.ts:289–307  ·  view source on GitHub ↗

Initialize asm.js module.

(
	binding: Binding<ExportType>,
	callback: InitCallback<ExportType>
)

Source from the content-addressed store, hash-verified

287/** Initialize asm.js module. */
288
289function initAsm<ExportType extends DefaultExportType>(
290 binding: Binding<ExportType>,
291 callback: InitCallback<ExportType>
292) {
293 const lib = binding.lib;
294
295 lib.locateFile = lib.locateFile || function(name: string) {
296 return(path.resolve(path.dirname(binding.binary.path), name));
297 };
298
299 // Load the Asm.js module.
300 require(binding.binary.path)(lib, (err: any, parts: Binding<ExportType>) => {
301 if(!err) {
302 for(let key of Object.keys(parts)) binding[key] = parts[key];
303 }
304
305 callback(err, binding);
306 });
307}
308
309/** Initialize native Node.js addon. */
310

Callers 1

initFunction · 0.85

Calls 1

resolveMethod · 0.80

Tested by

no test coverage detected