1 | // Type definitions for bindings 1.5
|
2 | // Project: https://github.com/TooTallNate/node-bindings
|
3 | // Definitions by: Daniel Perez Alvarez <https://github.com/unindented>
|
4 | // ExE Boss <https://github.com/ExE-Boss>
|
5 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
6 |
|
7 | /// <reference types="node"/>
|
8 |
|
9 | /**
|
10 | * The main `bindings()` function loads the compiled bindings for a given module.
|
11 | * It uses V8's Error API to determine the parent filename that this function is
|
12 | * being invoked from, which is then used to find the root directory.
|
13 | */
|
14 | declare function bindings(mod: string | bindings.Options): any;
|
15 | declare namespace bindings {
|
16 | interface Options {
|
17 | /** @default process.env.NODE_BINDINGS_ARROW || ' → ' */
|
18 | arrow?: string | undefined;
|
19 | /** @default process.env.NODE_BINDINGS_COMPILED_DIR || 'compiled' */
|
20 | compiled?: string | undefined;
|
21 | /** @default process.platform */
|
22 | platform?: NodeJS.Platform | undefined;
|
23 | /** @default process.arch */
|
24 | arch?: string | undefined;
|
25 | /** @default `node-v${process.versions.modules}-${process.platform}-${process.arch}` */
|
26 | nodePreGyp?: string | undefined;
|
27 | /** @default process.versions.node */
|
28 | version?: string | undefined;
|
29 | /** @default 'bindings.node' */
|
30 | bindings?: string | undefined;
|
31 | try?: ReadonlyArray<ReadonlyArray<string>> | undefined;
|
32 | }
|
33 |
|
34 | /**
|
35 | * Gets the filename of the JavaScript file that invokes this function.
|
36 | * Used to help find the root directory of a module.
|
37 | * Optionally accepts an filename argument to skip when searching for the invoking filename
|
38 | */
|
39 | function getFileName(calling_file?: string): string;
|
40 |
|
41 | /**
|
42 | * Gets the root directory of a module, given an arbitrary filename
|
43 | * somewhere in the module tree. The "root directory" is the directory
|
44 | * containing the `package.json` file.
|
45 | *
|
46 | * In: /home/nate/node-native-module/lib/index.js
|
47 | * Out: /home/nate/node-native-module
|
48 | */
|
49 | function getRoot(file: string): string;
|
50 | }
|
51 |
|
52 | export = bindings;
|