UNPKG

2.7 kBMarkdownView Raw
1# Installation
2> `npm install --save @types/bindings`
3
4# Summary
5This package contains type definitions for bindings (https://github.com/TooTallNate/node-bindings).
6
7# Details
8Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/bindings.
9## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/bindings/index.d.ts)
10````ts
11/// <reference types="node"/>
12
13/**
14 * The main `bindings()` function loads the compiled bindings for a given module.
15 * It uses V8's Error API to determine the parent filename that this function is
16 * being invoked from, which is then used to find the root directory.
17 */
18declare function bindings(mod: string | bindings.Options): any;
19declare namespace bindings {
20 interface Options {
21 /** @default process.env.NODE_BINDINGS_ARROW || ' → ' */
22 arrow?: string | undefined;
23 /** @default process.env.NODE_BINDINGS_COMPILED_DIR || 'compiled' */
24 compiled?: string | undefined;
25 /** @default process.platform */
26 platform?: NodeJS.Platform | undefined;
27 /** @default process.arch */
28 arch?: string | undefined;
29 /** @default `node-v${process.versions.modules}-${process.platform}-${process.arch}` */
30 nodePreGyp?: string | undefined;
31 /** @default process.versions.node */
32 version?: string | undefined;
33 /** @default 'bindings.node' */
34 bindings?: string | undefined;
35 /* @default exports.getRoot(exports.getFileName()) */
36 module_root?: string | undefined;
37 /* @default (build/|out/)?(Debug|Release|default) and others */
38 try?: ReadonlyArray<readonly string[]> | undefined;
39 }
40
41 /**
42 * Gets the filename of the JavaScript file that invokes this function.
43 * Used to help find the root directory of a module.
44 * Optionally accepts an filename argument to skip when searching for the invoking filename
45 */
46 function getFileName(calling_file?: string): string;
47
48 /**
49 * Gets the root directory of a module, given an arbitrary filename
50 * somewhere in the module tree. The "root directory" is the directory
51 * containing the `package.json` file.
52 *
53 * In: /home/nate/node-native-module/lib/index.js
54 * Out: /home/nate/node-native-module
55 */
56 function getRoot(file: string): string;
57}
58
59export = bindings;
60
61````
62
63### Additional Details
64 * Last updated: Mon, 20 Nov 2023 23:36:23 GMT
65 * Dependencies: [@types/node](https://npmjs.com/package/@types/node)
66
67# Credits
68These definitions were written by [Daniel Perez Alvarez](https://github.com/unindented), and [ExE Boss](https://github.com/ExE-Boss).
69
\No newline at end of file