Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

globals.d.ts 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. // Declare "static" methods in Error
  2. interface ErrorConstructor {
  3. /** Create .stack property on a target object */
  4. captureStackTrace(targetObject: object, constructorOpt?: Function): void;
  5. /**
  6. * Optional override for formatting stack traces
  7. *
  8. * @see https://v8.dev/docs/stack-trace-api#customizing-stack-traces
  9. */
  10. prepareStackTrace?: (err: Error, stackTraces: NodeJS.CallSite[]) => any;
  11. stackTraceLimit: number;
  12. }
  13. // Node.js ESNEXT support
  14. interface String {
  15. /** Removes whitespace from the left end of a string. */
  16. trimLeft(): string;
  17. /** Removes whitespace from the right end of a string. */
  18. trimRight(): string;
  19. /** Returns a copy with leading whitespace removed. */
  20. trimStart(): string;
  21. /** Returns a copy with trailing whitespace removed. */
  22. trimEnd(): string;
  23. }
  24. interface ImportMeta {
  25. url: string;
  26. }
  27. /*-----------------------------------------------*
  28. * *
  29. * GLOBAL *
  30. * *
  31. ------------------------------------------------*/
  32. // For backwards compability
  33. interface NodeRequire extends NodeJS.Require {}
  34. interface RequireResolve extends NodeJS.RequireResolve {}
  35. interface NodeModule extends NodeJS.Module {}
  36. declare var process: NodeJS.Process;
  37. declare var console: Console;
  38. declare var __filename: string;
  39. declare var __dirname: string;
  40. declare function setTimeout(callback: (...args: any[]) => void, ms?: number, ...args: any[]): NodeJS.Timeout;
  41. declare namespace setTimeout {
  42. function __promisify__(ms: number): Promise<void>;
  43. function __promisify__<T>(ms: number, value: T): Promise<T>;
  44. }
  45. declare function clearTimeout(timeoutId: NodeJS.Timeout): void;
  46. declare function setInterval(callback: (...args: any[]) => void, ms?: number, ...args: any[]): NodeJS.Timeout;
  47. declare function clearInterval(intervalId: NodeJS.Timeout): void;
  48. declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): NodeJS.Immediate;
  49. declare namespace setImmediate {
  50. function __promisify__(): Promise<void>;
  51. function __promisify__<T>(value: T): Promise<T>;
  52. }
  53. declare function clearImmediate(immediateId: NodeJS.Immediate): void;
  54. declare function queueMicrotask(callback: () => void): void;
  55. declare var require: NodeRequire;
  56. declare var module: NodeModule;
  57. // Same as module.exports
  58. declare var exports: any;
  59. // Buffer class
  60. type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex";
  61. type WithImplicitCoercion<T> = T | { valueOf(): T };
  62. /**
  63. * Raw data is stored in instances of the Buffer class.
  64. * A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized.
  65. * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
  66. */
  67. declare class Buffer extends Uint8Array {
  68. /**
  69. * Allocates a new buffer containing the given {str}.
  70. *
  71. * @param str String to store in buffer.
  72. * @param encoding encoding to use, optional. Default is 'utf8'
  73. * @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead.
  74. */
  75. constructor(str: string, encoding?: BufferEncoding);
  76. /**
  77. * Allocates a new buffer of {size} octets.
  78. *
  79. * @param size count of octets to allocate.
  80. * @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`).
  81. */
  82. constructor(size: number);
  83. /**
  84. * Allocates a new buffer containing the given {array} of octets.
  85. *
  86. * @param array The octets to store.
  87. * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
  88. */
  89. constructor(array: Uint8Array);
  90. /**
  91. * Produces a Buffer backed by the same allocated memory as
  92. * the given {ArrayBuffer}/{SharedArrayBuffer}.
  93. *
  94. *
  95. * @param arrayBuffer The ArrayBuffer with which to share memory.
  96. * @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
  97. */
  98. constructor(arrayBuffer: ArrayBuffer | SharedArrayBuffer);
  99. /**
  100. * Allocates a new buffer containing the given {array} of octets.
  101. *
  102. * @param array The octets to store.
  103. * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
  104. */
  105. constructor(array: ReadonlyArray<any>);
  106. /**
  107. * Copies the passed {buffer} data onto a new {Buffer} instance.
  108. *
  109. * @param buffer The buffer to copy.
  110. * @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead.
  111. */
  112. constructor(buffer: Buffer);
  113. /**
  114. * When passed a reference to the .buffer property of a TypedArray instance,
  115. * the newly created Buffer will share the same allocated memory as the TypedArray.
  116. * The optional {byteOffset} and {length} arguments specify a memory range
  117. * within the {arrayBuffer} that will be shared by the Buffer.
  118. *
  119. * @param arrayBuffer The .buffer property of any TypedArray or a new ArrayBuffer()
  120. */
  121. static from(arrayBuffer: WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer>, byteOffset?: number, length?: number): Buffer;
  122. /**
  123. * Creates a new Buffer using the passed {data}
  124. * @param data data to create a new Buffer
  125. */
  126. static from(data: Uint8Array | ReadonlyArray<number>): Buffer;
  127. static from(data: WithImplicitCoercion<Uint8Array | ReadonlyArray<number> | string>): Buffer;
  128. /**
  129. * Creates a new Buffer containing the given JavaScript string {str}.
  130. * If provided, the {encoding} parameter identifies the character encoding.
  131. * If not provided, {encoding} defaults to 'utf8'.
  132. */
  133. static from(str: WithImplicitCoercion<string> | { [Symbol.toPrimitive](hint: 'string'): string }, encoding?: BufferEncoding): Buffer;
  134. /**
  135. * Creates a new Buffer using the passed {data}
  136. * @param values to create a new Buffer
  137. */
  138. static of(...items: number[]): Buffer;
  139. /**
  140. * Returns true if {obj} is a Buffer
  141. *
  142. * @param obj object to test.
  143. */
  144. static isBuffer(obj: any): obj is Buffer;
  145. /**
  146. * Returns true if {encoding} is a valid encoding argument.
  147. * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
  148. *
  149. * @param encoding string to test.
  150. */
  151. static isEncoding(encoding: string): encoding is BufferEncoding;
  152. /**
  153. * Gives the actual byte length of a string. encoding defaults to 'utf8'.
  154. * This is not the same as String.prototype.length since that returns the number of characters in a string.
  155. *
  156. * @param string string to test.
  157. * @param encoding encoding used to evaluate (defaults to 'utf8')
  158. */
  159. static byteLength(
  160. string: string | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
  161. encoding?: BufferEncoding
  162. ): number;
  163. /**
  164. * Returns a buffer which is the result of concatenating all the buffers in the list together.
  165. *
  166. * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
  167. * If the list has exactly one item, then the first item of the list is returned.
  168. * If the list has more than one item, then a new Buffer is created.
  169. *
  170. * @param list An array of Buffer objects to concatenate
  171. * @param totalLength Total length of the buffers when concatenated.
  172. * If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
  173. */
  174. static concat(list: ReadonlyArray<Uint8Array>, totalLength?: number): Buffer;
  175. /**
  176. * The same as buf1.compare(buf2).
  177. */
  178. static compare(buf1: Uint8Array, buf2: Uint8Array): number;
  179. /**
  180. * Allocates a new buffer of {size} octets.
  181. *
  182. * @param size count of octets to allocate.
  183. * @param fill if specified, buffer will be initialized by calling buf.fill(fill).
  184. * If parameter is omitted, buffer will be filled with zeros.
  185. * @param encoding encoding used for call to buf.fill while initalizing
  186. */
  187. static alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer;
  188. /**
  189. * Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents
  190. * of the newly created Buffer are unknown and may contain sensitive data.
  191. *
  192. * @param size count of octets to allocate
  193. */
  194. static allocUnsafe(size: number): Buffer;
  195. /**
  196. * Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents
  197. * of the newly created Buffer are unknown and may contain sensitive data.
  198. *
  199. * @param size count of octets to allocate
  200. */
  201. static allocUnsafeSlow(size: number): Buffer;
  202. /**
  203. * This is the number of bytes used to determine the size of pre-allocated, internal Buffer instances used for pooling. This value may be modified.
  204. */
  205. static poolSize: number;
  206. write(string: string, encoding?: BufferEncoding): number;
  207. write(string: string, offset: number, encoding?: BufferEncoding): number;
  208. write(string: string, offset: number, length: number, encoding?: BufferEncoding): number;
  209. toString(encoding?: BufferEncoding, start?: number, end?: number): string;
  210. toJSON(): { type: 'Buffer'; data: number[] };
  211. equals(otherBuffer: Uint8Array): boolean;
  212. compare(
  213. otherBuffer: Uint8Array,
  214. targetStart?: number,
  215. targetEnd?: number,
  216. sourceStart?: number,
  217. sourceEnd?: number
  218. ): number;
  219. copy(targetBuffer: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
  220. /**
  221. * Returns a new `Buffer` that references **the same memory as the original**, but offset and cropped by the start and end indices.
  222. *
  223. * This method is incompatible with `Uint8Array#slice()`, which returns a copy of the original memory.
  224. *
  225. * @param begin Where the new `Buffer` will start. Default: `0`.
  226. * @param end Where the new `Buffer` will end (not inclusive). Default: `buf.length`.
  227. */
  228. slice(begin?: number, end?: number): Buffer;
  229. /**
  230. * Returns a new `Buffer` that references **the same memory as the original**, but offset and cropped by the start and end indices.
  231. *
  232. * This method is compatible with `Uint8Array#subarray()`.
  233. *
  234. * @param begin Where the new `Buffer` will start. Default: `0`.
  235. * @param end Where the new `Buffer` will end (not inclusive). Default: `buf.length`.
  236. */
  237. subarray(begin?: number, end?: number): Buffer;
  238. writeBigInt64BE(value: bigint, offset?: number): number;
  239. writeBigInt64LE(value: bigint, offset?: number): number;
  240. writeBigUInt64BE(value: bigint, offset?: number): number;
  241. writeBigUInt64LE(value: bigint, offset?: number): number;
  242. writeUIntLE(value: number, offset: number, byteLength: number): number;
  243. writeUIntBE(value: number, offset: number, byteLength: number): number;
  244. writeIntLE(value: number, offset: number, byteLength: number): number;
  245. writeIntBE(value: number, offset: number, byteLength: number): number;
  246. readBigUInt64BE(offset?: number): bigint;
  247. readBigUInt64LE(offset?: number): bigint;
  248. readBigInt64BE(offset?: number): bigint;
  249. readBigInt64LE(offset?: number): bigint;
  250. readUIntLE(offset: number, byteLength: number): number;
  251. readUIntBE(offset: number, byteLength: number): number;
  252. readIntLE(offset: number, byteLength: number): number;
  253. readIntBE(offset: number, byteLength: number): number;
  254. readUInt8(offset?: number): number;
  255. readUInt16LE(offset?: number): number;
  256. readUInt16BE(offset?: number): number;
  257. readUInt32LE(offset?: number): number;
  258. readUInt32BE(offset?: number): number;
  259. readInt8(offset?: number): number;
  260. readInt16LE(offset?: number): number;
  261. readInt16BE(offset?: number): number;
  262. readInt32LE(offset?: number): number;
  263. readInt32BE(offset?: number): number;
  264. readFloatLE(offset?: number): number;
  265. readFloatBE(offset?: number): number;
  266. readDoubleLE(offset?: number): number;
  267. readDoubleBE(offset?: number): number;
  268. reverse(): this;
  269. swap16(): Buffer;
  270. swap32(): Buffer;
  271. swap64(): Buffer;
  272. writeUInt8(value: number, offset?: number): number;
  273. writeUInt16LE(value: number, offset?: number): number;
  274. writeUInt16BE(value: number, offset?: number): number;
  275. writeUInt32LE(value: number, offset?: number): number;
  276. writeUInt32BE(value: number, offset?: number): number;
  277. writeInt8(value: number, offset?: number): number;
  278. writeInt16LE(value: number, offset?: number): number;
  279. writeInt16BE(value: number, offset?: number): number;
  280. writeInt32LE(value: number, offset?: number): number;
  281. writeInt32BE(value: number, offset?: number): number;
  282. writeFloatLE(value: number, offset?: number): number;
  283. writeFloatBE(value: number, offset?: number): number;
  284. writeDoubleLE(value: number, offset?: number): number;
  285. writeDoubleBE(value: number, offset?: number): number;
  286. fill(value: string | Uint8Array | number, offset?: number, end?: number, encoding?: BufferEncoding): this;
  287. indexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
  288. lastIndexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
  289. entries(): IterableIterator<[number, number]>;
  290. includes(value: string | number | Buffer, byteOffset?: number, encoding?: BufferEncoding): boolean;
  291. keys(): IterableIterator<number>;
  292. values(): IterableIterator<number>;
  293. }
  294. /*----------------------------------------------*
  295. * *
  296. * GLOBAL INTERFACES *
  297. * *
  298. *-----------------------------------------------*/
  299. declare namespace NodeJS {
  300. interface InspectOptions {
  301. /**
  302. * If set to `true`, getters are going to be
  303. * inspected as well. If set to `'get'` only getters without setter are going
  304. * to be inspected. If set to `'set'` only getters having a corresponding
  305. * setter are going to be inspected. This might cause side effects depending on
  306. * the getter function.
  307. * @default `false`
  308. */
  309. getters?: 'get' | 'set' | boolean;
  310. showHidden?: boolean;
  311. /**
  312. * @default 2
  313. */
  314. depth?: number | null;
  315. colors?: boolean;
  316. customInspect?: boolean;
  317. showProxy?: boolean;
  318. maxArrayLength?: number | null;
  319. /**
  320. * Specifies the maximum number of characters to
  321. * include when formatting. Set to `null` or `Infinity` to show all elements.
  322. * Set to `0` or negative to show no characters.
  323. * @default Infinity
  324. */
  325. maxStringLength?: number | null;
  326. breakLength?: number;
  327. /**
  328. * Setting this to `false` causes each object key
  329. * to be displayed on a new line. It will also add new lines to text that is
  330. * longer than `breakLength`. If set to a number, the most `n` inner elements
  331. * are united on a single line as long as all properties fit into
  332. * `breakLength`. Short array elements are also grouped together. Note that no
  333. * text will be reduced below 16 characters, no matter the `breakLength` size.
  334. * For more information, see the example below.
  335. * @default `true`
  336. */
  337. compact?: boolean | number;
  338. sorted?: boolean | ((a: string, b: string) => number);
  339. }
  340. interface CallSite {
  341. /**
  342. * Value of "this"
  343. */
  344. getThis(): any;
  345. /**
  346. * Type of "this" as a string.
  347. * This is the name of the function stored in the constructor field of
  348. * "this", if available. Otherwise the object's [[Class]] internal
  349. * property.
  350. */
  351. getTypeName(): string | null;
  352. /**
  353. * Current function
  354. */
  355. getFunction(): Function | undefined;
  356. /**
  357. * Name of the current function, typically its name property.
  358. * If a name property is not available an attempt will be made to try
  359. * to infer a name from the function's context.
  360. */
  361. getFunctionName(): string | null;
  362. /**
  363. * Name of the property [of "this" or one of its prototypes] that holds
  364. * the current function
  365. */
  366. getMethodName(): string | null;
  367. /**
  368. * Name of the script [if this function was defined in a script]
  369. */
  370. getFileName(): string | null;
  371. /**
  372. * Current line number [if this function was defined in a script]
  373. */
  374. getLineNumber(): number | null;
  375. /**
  376. * Current column number [if this function was defined in a script]
  377. */
  378. getColumnNumber(): number | null;
  379. /**
  380. * A call site object representing the location where eval was called
  381. * [if this function was created using a call to eval]
  382. */
  383. getEvalOrigin(): string | undefined;
  384. /**
  385. * Is this a toplevel invocation, that is, is "this" the global object?
  386. */
  387. isToplevel(): boolean;
  388. /**
  389. * Does this call take place in code defined by a call to eval?
  390. */
  391. isEval(): boolean;
  392. /**
  393. * Is this call in native V8 code?
  394. */
  395. isNative(): boolean;
  396. /**
  397. * Is this a constructor call?
  398. */
  399. isConstructor(): boolean;
  400. }
  401. interface ErrnoException extends Error {
  402. errno?: number;
  403. code?: string;
  404. path?: string;
  405. syscall?: string;
  406. stack?: string;
  407. }
  408. interface ReadableStream extends EventEmitter {
  409. readable: boolean;
  410. read(size?: number): string | Buffer;
  411. setEncoding(encoding: BufferEncoding): this;
  412. pause(): this;
  413. resume(): this;
  414. isPaused(): boolean;
  415. pipe<T extends WritableStream>(destination: T, options?: { end?: boolean; }): T;
  416. unpipe(destination?: WritableStream): this;
  417. unshift(chunk: string | Uint8Array, encoding?: BufferEncoding): void;
  418. wrap(oldStream: ReadableStream): this;
  419. [Symbol.asyncIterator](): AsyncIterableIterator<string | Buffer>;
  420. }
  421. interface WritableStream extends EventEmitter {
  422. writable: boolean;
  423. write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean;
  424. write(str: string, encoding?: BufferEncoding, cb?: (err?: Error | null) => void): boolean;
  425. end(cb?: () => void): void;
  426. end(data: string | Uint8Array, cb?: () => void): void;
  427. end(str: string, encoding?: BufferEncoding, cb?: () => void): void;
  428. }
  429. interface ReadWriteStream extends ReadableStream, WritableStream { }
  430. interface Global {
  431. Array: typeof Array;
  432. ArrayBuffer: typeof ArrayBuffer;
  433. Boolean: typeof Boolean;
  434. Buffer: typeof Buffer;
  435. DataView: typeof DataView;
  436. Date: typeof Date;
  437. Error: typeof Error;
  438. EvalError: typeof EvalError;
  439. Float32Array: typeof Float32Array;
  440. Float64Array: typeof Float64Array;
  441. Function: typeof Function;
  442. Infinity: typeof Infinity;
  443. Int16Array: typeof Int16Array;
  444. Int32Array: typeof Int32Array;
  445. Int8Array: typeof Int8Array;
  446. Intl: typeof Intl;
  447. JSON: typeof JSON;
  448. Map: MapConstructor;
  449. Math: typeof Math;
  450. NaN: typeof NaN;
  451. Number: typeof Number;
  452. Object: typeof Object;
  453. Promise: typeof Promise;
  454. RangeError: typeof RangeError;
  455. ReferenceError: typeof ReferenceError;
  456. RegExp: typeof RegExp;
  457. Set: SetConstructor;
  458. String: typeof String;
  459. Symbol: Function;
  460. SyntaxError: typeof SyntaxError;
  461. TypeError: typeof TypeError;
  462. URIError: typeof URIError;
  463. Uint16Array: typeof Uint16Array;
  464. Uint32Array: typeof Uint32Array;
  465. Uint8Array: typeof Uint8Array;
  466. Uint8ClampedArray: typeof Uint8ClampedArray;
  467. WeakMap: WeakMapConstructor;
  468. WeakSet: WeakSetConstructor;
  469. clearImmediate: (immediateId: Immediate) => void;
  470. clearInterval: (intervalId: Timeout) => void;
  471. clearTimeout: (timeoutId: Timeout) => void;
  472. decodeURI: typeof decodeURI;
  473. decodeURIComponent: typeof decodeURIComponent;
  474. encodeURI: typeof encodeURI;
  475. encodeURIComponent: typeof encodeURIComponent;
  476. escape: (str: string) => string;
  477. eval: typeof eval;
  478. global: Global;
  479. isFinite: typeof isFinite;
  480. isNaN: typeof isNaN;
  481. parseFloat: typeof parseFloat;
  482. parseInt: typeof parseInt;
  483. setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => Immediate;
  484. setInterval: (callback: (...args: any[]) => void, ms?: number, ...args: any[]) => Timeout;
  485. setTimeout: (callback: (...args: any[]) => void, ms?: number, ...args: any[]) => Timeout;
  486. queueMicrotask: typeof queueMicrotask;
  487. undefined: typeof undefined;
  488. unescape: (str: string) => string;
  489. gc: () => void;
  490. v8debug?: any;
  491. }
  492. interface RefCounted {
  493. ref(): this;
  494. unref(): this;
  495. }
  496. // compatibility with older typings
  497. interface Timer extends RefCounted {
  498. hasRef(): boolean;
  499. refresh(): this;
  500. [Symbol.toPrimitive](): number;
  501. }
  502. interface Immediate extends RefCounted {
  503. hasRef(): boolean;
  504. _onImmediate: Function; // to distinguish it from the Timeout class
  505. }
  506. interface Timeout extends Timer {
  507. hasRef(): boolean;
  508. refresh(): this;
  509. [Symbol.toPrimitive](): number;
  510. }
  511. type TypedArray =
  512. | Uint8Array
  513. | Uint8ClampedArray
  514. | Uint16Array
  515. | Uint32Array
  516. | Int8Array
  517. | Int16Array
  518. | Int32Array
  519. | BigUint64Array
  520. | BigInt64Array
  521. | Float32Array
  522. | Float64Array;
  523. type ArrayBufferView = TypedArray | DataView;
  524. interface Require {
  525. (id: string): any;
  526. resolve: RequireResolve;
  527. cache: Dict<NodeModule>;
  528. /**
  529. * @deprecated
  530. */
  531. extensions: RequireExtensions;
  532. main: Module | undefined;
  533. }
  534. interface RequireResolve {
  535. (id: string, options?: { paths?: string[]; }): string;
  536. paths(request: string): string[] | null;
  537. }
  538. interface RequireExtensions extends Dict<(m: Module, filename: string) => any> {
  539. '.js': (m: Module, filename: string) => any;
  540. '.json': (m: Module, filename: string) => any;
  541. '.node': (m: Module, filename: string) => any;
  542. }
  543. interface Module {
  544. exports: any;
  545. require: Require;
  546. id: string;
  547. filename: string;
  548. loaded: boolean;
  549. /** @deprecated since 14.6.0 Please use `require.main` and `module.children` instead. */
  550. parent: Module | null | undefined;
  551. children: Module[];
  552. /**
  553. * @since 11.14.0
  554. *
  555. * The directory name of the module. This is usually the same as the path.dirname() of the module.id.
  556. */
  557. path: string;
  558. paths: string[];
  559. }
  560. interface Dict<T> {
  561. [key: string]: T | undefined;
  562. }
  563. interface ReadOnlyDict<T> {
  564. readonly [key: string]: T | undefined;
  565. }
  566. }