UNPKG

3.11 kBMarkdownView Raw
1# Installation
2> `npm install --save @types/browser-resolve`
3
4# Summary
5This package contains type definitions for browser-resolve (https://github.com/defunctzombie/node-browser-resolve).
6
7# Details
8Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/browser-resolve.
9## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/browser-resolve/index.d.ts)
10````ts
11// Type definitions for browser-resolve 2.0
12// Project: https://github.com/defunctzombie/node-browser-resolve
13// Definitions by: Mario Nebl <https://github.com/marionebl>
14// Piotr Błażejewicz <https://github.com/peterblazejewicz>
15// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
16
17import * as resv from 'resolve';
18
19/**
20 * Resolve a module path and call cb(err, path)
21 *
22 * @param id Identifier to resolve
23 * @param callback
24 */
25declare function resolve(id: string, cb: resolve.Callback): void;
26
27/**
28 * Resolve a module path and call cb(err, path)
29 *
30 * @param id Identifier to resolve
31 * @param options Options to use for resolving, optional.
32 * @param callback
33 */
34declare function resolve(id: string, opts: resolve.AsyncOpts, cb: resolve.Callback): void;
35
36declare namespace resolve {
37 interface Opts {
38 /**
39 * directory to begin resolving from
40 */
41 basedir?: string | undefined;
42 /**
43 * the 'browser' property to use from package.json
44 * @default 'browser'
45 */
46 browser?: string | undefined;
47 /**
48 * the calling filename where the require() call originated (in the source)
49 */
50 filename?: string | undefined;
51 /**
52 * modules object with id to path mappings to consult before doing manual resolution
53 * (use to provide core modules)
54 */
55 modules?: { [id: string]: string } | undefined;
56 /**
57 * transform the parsed package.json contents before looking at the main field
58 */
59 packageFilter?: ((info: any, pkgdir: string) => any) | undefined;
60 /**
61 * require.paths array to use if nothing is found on the normal node_modules recursive walk
62 */
63 paths?: string[] | undefined;
64 }
65
66 type AsyncOpts = resv.AsyncOpts & Opts;
67 type SyncOpts = resv.SyncOpts & Opts;
68
69 /**
70 * Callback invoked when resolving asynchronously
71 * @param error
72 * @param resolved Absolute path to resolved identifier
73 */
74 type Callback = (err: Error | null, resolved?: string) => void;
75
76 /**
77 * Returns a module path
78 * @param id Identifier to resolve
79 * @param options Options to use for resolving.
80 */
81 function sync(id: string, opts?: SyncOpts): string;
82}
83
84export = resolve;
85
86````
87
88### Additional Details
89 * Last updated: Tue, 06 Jul 2021 18:05:45 GMT
90 * Dependencies: [@types/resolve](https://npmjs.com/package/@types/resolve)
91 * Global values: none
92
93# Credits
94These definitions were written by [Mario Nebl](https://github.com/marionebl), and [Piotr Błażejewicz](https://github.com/peterblazejewicz).
95
\No newline at end of file