|
5 | 5 |
|
6 | 6 | /************************************************
|
7 | 7 | * *
|
8 |
| -* Node.js v0.10.1 API * |
| 8 | +* Node.js v0.10.x API * |
9 | 9 | * *
|
10 | 10 | ************************************************/
|
11 | 11 |
|
| 12 | +interface NodeError { |
| 13 | + /** |
| 14 | + * Returns a string describing the point in the code at which the Error was instantiated. |
| 15 | + * |
| 16 | + * For example: |
| 17 | + * |
| 18 | + * ``` |
| 19 | + * Error: Things keep happening! |
| 20 | + * at /home/gbusey/file.js:525:2 |
| 21 | + * at Frobnicator.refrobulate (/home/gbusey/business-logic.js:424:21) |
| 22 | + * at Actor.<anonymous> (/home/gbusey/actors.js:400:8) |
| 23 | + * at increaseSynergy (/home/gbusey/actors.js:701:6) |
| 24 | + * ``` |
| 25 | + * |
| 26 | + * The first line is formatted as <error class name>: <error message>, and is followed by a series of stack frames (each line beginning with "at "). Each frame describes a call site within the code that lead to the error being generated. V8 attempts to display a name for each function (by variable name, function name, or object method name), but occasionally it will not be able to find a suitable name. If V8 cannot determine a name for the function, only location information will be displayed for that frame. Otherwise, the determined function name will be displayed with location information appended in parentheses. |
| 27 | + */ |
| 28 | + stack?: string; |
| 29 | + |
| 30 | + /** |
| 31 | + * Returns the string description of error as set by calling new Error(message). The message passed to the constructor will also appear in the first line of the stack trace of the Error, however changing this property after the Error object is created may not change the first line of the stack trace. |
| 32 | + * |
| 33 | + * ``` |
| 34 | + * const err = new Error('The message'); |
| 35 | + * console.log(err.message); |
| 36 | + * // Prints: The message |
| 37 | + * ``` |
| 38 | + */ |
| 39 | + message: string; |
| 40 | +} |
| 41 | + |
| 42 | +interface Error extends NodeError { } |
| 43 | + |
| 44 | +interface ErrorConstructor { |
| 45 | + /** |
| 46 | + * Creates a `.stack` property on `targetObject`, which when accessed returns a string representing the location in the code at which `Error.captureStackTrace()`` was called. |
| 47 | + * |
| 48 | + * ```js |
| 49 | + * const myObject = {}; |
| 50 | + * Error.captureStackTrace(myObject); |
| 51 | + * myObject.stack // similar to `new Error().stack` |
| 52 | + * ``` |
| 53 | + * |
| 54 | + * The first line of the trace, instead of being prefixed with `ErrorType : message`, will be the result of calling `targetObject.toString()``. |
| 55 | + * |
| 56 | + * The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace. |
| 57 | + * |
| 58 | + * The constructorOpt argument is useful for hiding implementation details of error generation from an end user. For instance: |
| 59 | + * |
| 60 | + * ```js |
| 61 | + * function MyError() { |
| 62 | + * Error.captureStackTrace(this, MyError); |
| 63 | + * } |
| 64 | + * |
| 65 | + * // Without passing MyError to captureStackTrace, the MyError |
| 66 | + * // frame would should up in the .stack property. by passing |
| 67 | + * // the constructor, we omit that frame and all frames above it. |
| 68 | + * new MyError().stack |
| 69 | + * ``` |
| 70 | + */ |
| 71 | + captureStackTrace<T extends { stack?: string }>(targetObject: T, constructorOpt?: new () => T): void; |
| 72 | + |
| 73 | + /** |
| 74 | + * The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by `new Error().stack` or `Error.captureStackTrace(obj))``. |
| 75 | + * |
| 76 | + * The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. |
| 77 | + * |
| 78 | + * If set to a non-number value, or set to a negative number, stack traces will not capture any frames. |
| 79 | + */ |
| 80 | + stackTraceLimit: number; |
| 81 | +} |
| 82 | + |
12 | 83 | /************************************************
|
13 | 84 | * *
|
14 | 85 | * GLOBAL *
|
@@ -232,6 +303,7 @@ declare namespace NodeJS {
|
232 | 303 | ares: string;
|
233 | 304 | uv: string;
|
234 | 305 | zlib: string;
|
| 306 | + modules: string; |
235 | 307 | openssl: string;
|
236 | 308 | };
|
237 | 309 | config: {
|
@@ -1035,6 +1107,7 @@ declare module "fs" {
|
1035 | 1107 | bytesRead: number;
|
1036 | 1108 | path: string;
|
1037 | 1109 | close(): void;
|
| 1110 | + destroy(): void; |
1038 | 1111 | }
|
1039 | 1112 |
|
1040 | 1113 | export class WriteStream extends stream.Writable implements
|
@@ -1582,13 +1655,22 @@ declare module "path" {
|
1582 | 1655 | }
|
1583 | 1656 |
|
1584 | 1657 | declare module "string_decoder" {
|
1585 |
| - export interface NodeStringDecoder { |
| 1658 | + import * as buffer from "buffer"; |
| 1659 | + |
| 1660 | + export class StringDecoder { |
| 1661 | + /** |
| 1662 | + * @param encoding The character encoding the `StringDecoder` will use. Defaults to `'utf8'`. |
| 1663 | + */ |
| 1664 | + constructor(encoding?: buffer.Encoding); |
| 1665 | + /** |
| 1666 | + * Returns a decoded string. |
| 1667 | + */ |
1586 | 1668 | write(buffer: Buffer): string;
|
1587 |
| - detectIncompleteChar(buffer: Buffer): number; |
| 1669 | + /** |
| 1670 | + * Returns any trailing bytes that were left in the buffer. |
| 1671 | + */ |
| 1672 | + end(buffer?: Buffer): string; |
1588 | 1673 | }
|
1589 |
| - export var StringDecoder: { |
1590 |
| - new (encoding: string): NodeStringDecoder; |
1591 |
| - }; |
1592 | 1674 | }
|
1593 | 1675 |
|
1594 | 1676 | declare module "tls" {
|
|
0 commit comments