1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648
|
type BufferEncoding = "utf8" | "hex" | "base64" | "base64url";
type NjsFixedSizeArray<N extends number, T> = N extends 0 ? never[] : {
0: T;
length: N;
} & ReadonlyArray<T>;
type TypedArray =
| Uint8Array
| Uint8ClampedArray
| Uint16Array
| Uint32Array
| Int8Array
| Int16Array
| Int32Array
| Float32Array
| Float64Array;
/**
* Raw data is stored in instances of the `Buffer` class.
*/
declare class Buffer extends Uint8Array {
/**
* Allocates a new `Buffer` of a specified `size`.
*
* @param size The count of octets to allocate.
* @param fill If specified, the allocated `Buffer` will be initialized by calling `buf.fill(fill)`.
* Otherwise, the `Buffer` will be zero-filled.
* @param encoding The character encoding used for call to `buf.fill(fill, encoding)` while
* initalizing. Defaults to`'utf8'`.
*/
static alloc(size: number, fill?: string | Uint8Array | number, encoding?: BufferEncoding): Buffer;
/**
* The same as `Buffer.alloc()`, with the difference that the memory allocated for the buffer
* is not initialized, the contents of the new buffer is unknown and may contain sensitive data.
*
* @param size The count of octets to allocate.
*/
static allocUnsafe(size: number): Buffer;
/**
* Returns the byte length of the specified `value`, when encoded using `encoding`.
*
* @param value The value to test.
* @param encoding The character encoding used to evaluate `value` if `value` is a `string`.
* Defaults to `'utf8'`.
*/
static byteLength(value: string | Buffer | TypedArray | DataView | ArrayBuffer, encoding?: BufferEncoding): number;
/**
* Compares `buffer1` with `buffer2` when sorting arrays of buffer instances.
*
* @return
* - `0` if `buffer2` is the same as `buffer1`,
* - `1` if `buffer2` should come _before_ `buffer1` when sorted,
* - `-1` if `buffer2` should come _after_ `buffer1` when sorted.
*/
static compare(buf1: Uint8Array, buf2: Uint8Array): -1 | 0 | 1;
/**
* Returns a new `Buffer` which is the result of concatenating all the `Buffer` instances in
* the `list`. If there are no items in the `list` or the total length is 0, a new zero-length
* `Buffer` is returned.
*
* @param list An array of `Buffer` or `Uint8Array` objects to concatenate.
* @param totalLength Total length of the buffers when concatenated, coerced to an unsigned
* integer. If not specified, it is calculated from the `Buffer` instances in `list` by adding
* their lengths. If the combined length of the Buffers in list exceeds `totalLength`, the
* result is truncated to `totalLength`.
*/
static concat(list: Uint8Array[], totalLength?: number): Buffer;
/**
* @param arrayBuffer The `.buffer` property of any `TypedArray` or a `new ArrayBuffer()`.
* @param byteOffset An integer specifying the index of the first byte to expose. Defaults to `0`.
* @param length An integer specifying number of bytes to expose.
* Defaults to `arrayBuffer.byteLength - byteOffset`.
*/
static from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer;
/**
* Allocates a new `Buffer` using an array of bytes in the range `0 – 255`. Array entries
* outside that range will be truncated.
*
* @param data The data to create a new `Buffer`.
*/
static from(data: number[]): Buffer;
/**
* Copies the passed buffer `data` onto a new `Buffer` instance.
*
* @param data The buffer to copy.
*/
static from(data: Uint8Array): Buffer;
/**
* For objects whose `valueOf()` function returns a value not strictly equal to object, returns
* `Buffer.from(object.valueOf(), offsetOrEncoding, length)`.
*
* @param obj An object supporting `valueOf()`.
*/
static from(obj: { valueOf(): string | object }, byteOffset?: number, length?: number): Buffer;
/**
* Creates a new `Buffer` with a string `str`.
*
* @param str The string to create a new `Buffer`.
* @param encoding The character encoding to be used when converting a string into bytes.
* Defaults to `'utf8'`.
*/
static from(str: string, encoding?: BufferEncoding): Buffer;
/**
* Returns true if the `obj` is a `Buffer`.
*
* @param obj The object to test.
*/
static isBuffer(obj: any): obj is Buffer;
/**
* Returns `true` if `encoding` is the name of a supported character encoding.
*
* @param encoding The string to test.
*/
static isEncoding(encoding: string): encoding is BufferEncoding;
/**
* The underlying `ArrayBuffer` object based on which this `Buffer` object is created.
*/
readonly buffer: ArrayBuffer;
/**
* Specifies the `byteOffset` of the Buffer's underlying `ArrayBuffer` object.
*/
readonly byteOffset: number;
/**
* The number of bytes in this buffer.
*/
readonly length: number;
/**
* Constructor cannot be called.
*/
private constructor();
/**
* The index operator can be used to get and set the octet at position index in buffer.
* The values refer to individual bytes, so the legal value range is between 0 and 255 (decimal).
*/
[index: number]: number;
/**
* Compares this buffer (source) with the `target` and returns a number indicating whether this
* buffer comes before, after, or is the same as the `target` in sort order. Comparison is based
* on the actual sequence of bytes in each `Buffer`.
*
* @param target The target buffer for comparison.
* @param targetStart An integer specifying the offset within `target` at which to begin
* comparison. Defaults to `0`.
* @param targetEnd An integer specifying the offset within `target` at which to end comparison.
* Defaults to `target.length`.
* @param sourceStart An integer specifying the offset within this buffer at which to begin
* comparison. Defaults to `0`.
* @param sourceEnd An integer specifying the offset within this buffer at which to end comparison
* (not inclusive). Defaults to `buf.length`.
* @return
* - `0` if `target` is the same as this buffer,
* - `1` if `target` should come _before_ this buffer when sorted,
* - `-1` if `target` should come _after_ this buffer when sorted.
*/
compare(target: Uint8Array, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): -1 | 0 | 1;
/**
* Copies data from a region of this buffer to a region in `target`, even if the `target`
* memory region overlaps with this buffer.
*
* @param target The target buffer.
* @param targetStart An integer specifying the offset within `target` at which to begin writing.
* Defaults to `0`.
* @param sourceStart An integer specifying the offset within this buffer from which to begin
* copying. Defaults to `0`.
* @param sourceEnd An integer specifying the offset within this buffer at which to stop copying
* (not inclusive). Defaults to `buf.length`.
* @return The number of bytes copied.
*/
copy(target: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
/**
* Returns `true` if both this buffer and `other` buffer have exactly the same bytes.
*
* @param other The other buffer to compare with.
*/
equals(other: Uint8Array): boolean;
/**
* Fills this buffer with the specified `value`. If the `offset` and `end` are not specified,
* the entire buffer will be filled. The `value` is coerced to `uint32` if it is not a `string`,
* `Buffer`, or `integer`. If the resulting integer is greater than `255`, the buffer will be
* filled with `value` and `255`.
*
* @param value The value with which to fill this buffer.
* @param offset Number of bytes to skip before starting to fill this buffer. Defaults to `0`.
* @param end Where to stop filling this buffer (not inclusive). Defaults to `buf.length`.
* @param encoding The encoding for `value` if `value` is a `string`. Defaults to `'utf8'`.
*/
fill(value: string | Uint8Array | number, offset?: number, end?: number, encoding?: BufferEncoding): this;
/**
* Equivalent to `buf.indexOf() !== -1`, returns `true` if the `value` was found in this buffer.
*
* @param value What to search for. If a `number`, it must be between `0` and `255`.
* @param byteOffset Where to begin search in this buffer. Defaults to `0`.
* @param encoding The encoding for `value` if `value` is a `string`. Defaults to `'utf8'`.
*/
includes(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): boolean;
/**
* Returns an integer which is the index of the first occurrence of `value` in this buffer,
* or `-1` if this buffer does not contain `value`.
*
* @param value What to search for. If a `number`, it must be between `0` and `255`.
* @param byteOffset Where to begin search in this buffer. Defaults to `0`.
* @param encoding The encoding for `value` if `value` is a `string`. Defaults to `'utf8'`.
*/
indexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
/**
* The same as `buf.indexOf()`, except the last occurrence of the `value` is found instead of
* the first occurrence. If the `value` is an empty `string` or empty `Buffer`, `byteOffset`
* will be returned.
*
* @param value What to search for. If a `number`, it must be between `0` and `255`.
* @param byteOffset Where to begin search in this buffer. Defaults to `0`.
* @param encoding The encoding for `value` if `value` is a `string`. Defaults to `'utf8'`.
*/
lastIndexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
/**
* Reads the `byteLength` from this buffer at the specified `offset` and interprets the result
* as a big-endian, two's complement signed value supporting up to 48 bits of accuracy.
*
* @param offset An integer specifying the number of bytes to skip before starting to read.
* Must satisfy `0 <= offset <= buf.length - byteLength`.
* @param byteLength An integer between `1` and `6` specifying the number of bytes to read.
* Must satisfy `0 < byteLength <= 6`.
*/
readIntBE(offset: number, byteLength: number): number;
/**
* @see {Buffer.prototype.readIntBE}.
*/
readInt8(offset?: number): number;
/**
* @see {Buffer.prototype.readIntBE}.
*/
readInt16BE(offset?: number): number;
/**
* @see {Buffer.prototype.readIntBE}.
*/
readInt32BE(offset?: number): number;
/**
* Reads the `byteLength` from this buffer at the specified `offset` and interprets the result
* as a little-endian, two's complement signed value supporting up to 48 bits of accuracy.
*
* @param offset An integer specifying the number of bytes to skip before starting to read.
* Must satisfy `0 <= offset <= buf.length - byteLength`.
* @param byteLength An integer between `1` and `6` specifying the number of bytes to read.
* Must satisfy `0 < byteLength <= 6`.
*/
readIntLE(offset: number, byteLength: number): number;
/**
* @see {Buffer.prototype.readIntLE}.
*/
readInt16LE(offset?: number): number;
/**
* @see {Buffer.prototype.readIntLE}.
*/
readInt32LE(offset?: number): number;
/**
* Reads the `byteLength` from this buffer at the specified `offset` and interprets the result
* as a big-endian integer supporting up to 48 bits of accuracy.
*
* @param offset An integer specifying the number of bytes to skip before starting to read.
* Must satisfy `0 <= offset <= buf.length - byteLength`.
* @param byteLength An integer between `1` and `6` specifying the number of bytes to read.
* Must satisfy `0 < byteLength <= 6`.
*/
readUIntBE(offset: number, byteLength: number): number;
/**
* @see {Buffer.prototype.readUIntBE}.
*/
readUInt8(offset?: number): number;
/**
* @see {Buffer.prototype.readUIntBE}.
*/
readUInt16BE(offset?: number): number;
/**
* @see {Buffer.prototype.readUIntBE}.
*/
readUInt32BE(offset?: number): number;
/**
* Reads the `byteLength` from this buffer at the specified `offset` and interprets the result
* as a little-endian integer supporting up to 48 bits of accuracy.
*
* @param offset An integer specifying the number of bytes to skip before starting to read.
* Must satisfy `0 <= offset <= buf.length - byteLength`.
* @param byteLength An integer between `1` and `6` specifying the number of bytes to read.
* Must satisfy `0 < byteLength <= 6`.
*/
readUIntLE(offset: number, byteLength: number): number;
/**
* @see {Buffer.prototype.readUIntLE}.
*/
readUInt16LE(offset?: number): number;
/**
* @see {Buffer.prototype.readUIntLE}.
*/
readUInt32LE(offset?: number): number;
/**
* Reads a 64-bit, big-endian double from this buffer at the specified `offset`.
*
* @param offset An integer specifying the number of bytes to skip before starting to read.
* Must satisfy `0 <= offset <= buf.length - 8`. Defaults to `0`.
*/
readDoubleBE(offset?: number): number;
/**
* Reads a 64-bit, little-endian double from this buffer at the specified `offset`.
*
* @param offset An integer specifying the number of bytes to skip before starting to read.
* Must satisfy `0 <= offset <= buf.length - 8`. Defaults to `0`.
*/
readDoubleLE(offset?: number): number;
/**
* Reads a 32-bit, big-endian float from this buffer at the specified `offset`.
*
* @param offset An integer specifying the number of bytes to skip before starting to read.
* Must satisfy `0 <= offset <= buf.length - 4`. Defaults to `0`.
*/
readFloatBE(offset?: number): number;
/**
* Reads a 32-bit, little-endian float from this buffer at the specified `offset`.
*
* @param offset An integer specifying the number of bytes to skip before starting to read.
* Must satisfy `0 <= offset <= buf.length - 4`. Defaults to `0`.
*/
readFloatLE(offset?: number): number;
/**
* Returns a new `Buffer` that references **the same memory as the original**, but offset and
* cropped by `start` and `end`.
*
* @param start Where the new `Buffer` will start. Defaults to `0`.
* @param end Where the new `Buffer` will end (not inclusive). If `end` is greater than
* `buf.length`, the same result as that of end equal to `buf.length` is returned.
* Defaults to `buf.length`.
*/
subarray(start?: number, end?: number): Buffer;
/**
* Returns a new `Buffer` that references **the same memory as the original**, but offset and
* cropped by the `start` and end `values`.
*
* @param start Where the new `Buffer` will start. Defaults to `0`.
* @param end Where the new `Buffer` will end (not inclusive). Defaults to `buf.length`.
*/
slice(begin?: number, end?: number): Buffer;
/**
* Interprets this buffer as an array of unsigned 16-bit numbers and swaps the byte order
* in-place.
*
* @throws {RangeError} if `buf.length` is not a multiple of 2.
*/
swap16(): Buffer;
/**
* Interprets this buffer as an array of unsigned 32-bit numbers and swaps the byte order
* in-place.
*
* @throws {RangeError} if `buf.length` is not a multiple of 4.
*/
swap32(): Buffer;
/**
* Interprets this buffer as an array of 64-bit numbers and swaps byte order in-place.
*
* @throws {RangeError} if `buf.length` is not a multiple of 8.
*/
swap32(): Buffer;
/**
* Returns a JSON representation of this buffer. `JSON.stringify()` implicitly calls this
* function when stringifying a `Buffer` instance.
*/
toJSON(): { type: "Buffer"; data: number[] };
/**
* Decodes this buffer to a string according to the specified character `encoding`.
*
* @param encoding The character encoding. Defaults to `'utf8'`.
* @param start The byte offset to start decoding at. Defaults to `0`.
* @param end The byte offset to stop decoding at (not inclusive). Defaults to `buf.length`.
*/
toString(encoding?: BufferEncoding, start?: number, end?: number): string;
/**
* Writes a string `str` to this buffer at the `offset` according to the character `encoding`.
* If this buffer did not contain enough space to fit the entire string, only part of the
* string will be written, however, partially encoded characters will not be written.
*
* @param str The string to write into this buffer.
* @param offset An integer specifying the number of bytes to skip before starting to write `str`.
* Defaults to `0`.
* @param length An integer specifying the number of bytes to write.
* Defaults to `buf.length - offset`.
* @param encoding The character encoding of `str`. Defaults to `'utf8'`.
* @return Offset plus the number of bytes written.
*/
write(str: string, encoding?: BufferEncoding): number;
write(str: string, offset: number, encoding?: BufferEncoding): number;
write(str: string, offset: number, length: number, encoding?: BufferEncoding): number;
/**
* Writes `byteLength` bytes of `value` to this buffer at the specified `offset` as big-endian.
* Supports up to 48 bits of accuracy.
*
* @param value The number to be written into this buffer.
* @param offset An integer specifying the number of bytes to skip before starting to write.
* Must satisfy `0 <= offset <= buf.length - byteLength`.
* @param byteLength An integer between `1` and `6` specifying the number of bytes to read.
* Must satisfy `0 < byteLength <= 6`.
* @return Offset plus the number of bytes written.
*/
writeIntBE(value: number, offset: number, byteLength: number): number;
/**
* @see {Buffer.prototype.writeIntBE}.
*/
writeInt8(value: number, offset?: number): number;
/**
* @see {Buffer.prototype.writeIntBE}.
*/
writeInt16BE(value: number, offset?: number): number;
/**
* @see {Buffer.prototype.writeIntBE}.
*/
writeInt32BE(value: number, offset?: number): number;
/**
* Writes `byteLength` bytes of `value` to this buffer at the specified `offset` as
* little-endian. Supports up to 48 bits of accuracy.
*
* @param value The number to be written into this buffer.
* @param offset An integer specifying the number of bytes to skip before starting to write.
* Must satisfy `0 <= offset <= buf.length - byteLength`.
* @param byteLength An integer between `1` and `6` specifying the number of bytes to read.
* Must satisfy `0 < byteLength <= 6`.
* @return Offset plus the number of bytes written.
*/
writeIntLE(value: number, offset: number, byteLength: number): number;
/**
* @see {Buffer.prototype.writeIntLE}.
*/
writeInt16LE(value: number, offset?: number): number;
/**
* @see {Buffer.prototype.writeIntLE}.
*/
writeInt32LE(value: number, offset?: number): number;
/**
* Writes `byteLength` bytes of `value` to this buffer at the specified `offset` as big-endian.
* Supports up to 48 bits of accuracy.
*
* @param value The number to be written into this buffer.
* @param offset An integer specifying the number of bytes to skip before starting to write.
* Must satisfy `0 <= offset <= buf.length - byteLength`.
* @param byteLength An integer between `1` and `6` specifying the number of bytes to read.
* Must satisfy `0 < byteLength <= 6`.
* @return Offset plus the number of bytes written.
*/
writeUIntBE(value: number, offset: number, byteLength: number): number;
/**
* @see {Buffer.prototype.writeUIntBE}.
*/
writeUInt8(value: number, offset?: number): number;
/**
* @see {Buffer.prototype.writeUIntBE}.
*/
writeUInt16BE(value: number, offset?: number): number;
/**
* @see {Buffer.prototype.writeUIntBE}.
*/
writeUInt32BE(value: number, offset?: number): number;
/**
* Writes `byteLength` bytes of `value` to this buffer at the specified `offset` as
* little-endian. Supports up to 48 bits of accuracy.
*
* @param value The number to be written into this buffer.
* @param offset An integer specifying the number of bytes to skip before starting to write.
* Must satisfy `0 <= offset <= buf.length - byteLength`.
* @param byteLength An integer between `1` and `6` specifying the number of bytes to read.
* Must satisfy `0 < byteLength <= 6`.
* @return Offset plus the number of bytes written.
*/
writeUIntLE(value: number, offset: number, byteLength: number): number;
/**
* @see {Buffer.prototype.writeUIntLE}.
*/
writeUInt16LE(value: number, offset?: number): number;
/**
* @see {Buffer.prototype.writeUIntLE}.
*/
writeUInt32LE(value: number, offset?: number): number;
/**
* Writes the `value` to this buffer at the specified `offset` as big-endian.
*
* @param value The number to be written into this buffer.
* @param offset An integer specifying the number of bytes to skip before starting to write.
* Must satisfy `0 <= offset <= buf.length - 8`. Defaults to `0`.
* @return Offset plus the number of bytes written.
*/
writeDoubleBE(value: number, offset?: number): number;
/**
* Writes the `value` to this buffer at the specified `offset` as little-endian.
*
* @param value The number to be written into this buffer.
* @param offset An integer specifying the number of bytes to skip before starting to write.
* Must satisfy `0 <= offset <= buf.length - 8`. Defaults to `0`.
* @return Offset plus the number of bytes written.
*/
writeDoubleLE(value: number, offset?: number): number;
/**
* Writes the `value` to this buffer at the specified `offset` as big-endian.
*
* @param value The number to be written into this buffer.
* @param offset An integer specifying the number of bytes to skip before starting to write.
* Must satisfy `0 <= offset <= buf.length - 4`. Defaults to `0`.
* @return Offset plus the number of bytes written.
*/
writeFloatBE(value: number, offset?: number): number;
/**
* Writes the `value` to this buffer at the specified `offset` as little-endian.
*
* @param value The number to be written into this buffer.
* @param offset An integer specifying the number of bytes to skip before starting to write.
* Must satisfy `0 <= offset <= buf.length - 4`. Defaults to `0`.
* @return Offset plus the number of bytes written.
*/
writeFloatLE(value: number, offset?: number): number;
}
type NjsStringOrBuffer = string | Buffer | DataView | TypedArray | ArrayBuffer;
type NjsBuffer = Buffer | DataView | TypedArray;
// Global objects
interface NjsGlobal {
/**
* Returns current njs version as a string.
* For example, '0.7.4'.
*/
readonly version: string;
/**
* Returns a number with the current version of njs.
* For example, “0.7.4” is returned as 0x000704.
* @since 0.7.4
*/
readonly version_number: number;
dump(value: any, indent?: number): string;
/**
* Registers a callback for the "exit" event. The callback is called before
* the VM is destroyed.
*/
on(event: "exit", callback: () => void): void;
}
declare const njs: NjsGlobal;
interface NjsEnv {
readonly [prop: string]: string;
}
interface NjsProcess {
readonly pid: number;
readonly ppid: number;
readonly argv: string[];
readonly env: NjsEnv;
/**
* Send signal to a process by its PID.
* @since 0.8.8
*/
kill(pid: number, signal?: string | number): true;
}
declare const process: NjsProcess;
/**
* A value returned by `setTimeout()` and `setImmediate()` functions. It's an positive integer now,
* but this may be changed in future, so it should be treated as an opaque value.
*/
type TimerHandle = number & { readonly '': unique symbol };
/**
* Schedules the "immediate" execution of the given function after I/O events' callbacks.
*
* @param callback The function to call.
* @param args Optional arguments to pass to the `callback` function.
* @returns A value which identifies the timer created by the call.
*
* @throws {TypeError} if `callback` is not a function.
* @throws {InternalError} if timers are not supported by host environment.
*/
declare function setImmediate<TArgs extends any[]>(callback: (...args: TArgs) => void, ...args: TArgs): TimerHandle;
/**
* Schedules a timer which executes the given function after the specified delay.
*
* @param callback The function to call when the timer elapses.
* @param delay The number of milliseconds to wait before calling the `callback`. Defaults to `0`,
* meaning execute "immediately", or more accurately, the next event cycle.
* @param args Optional arguments to pass to the `callback` function.
* @returns A value which identifies the timer created by the call; it can be passed to
* `clearTimeout()` to cancel the timeout.
*
* @throws {TypeError} if `callback` is not a function.
* @throws {InternalError} if timers are not supported by host environment.
*/
declare function setTimeout<TArgs extends any[]>(callback: (...args: TArgs) => void, delay?: number, ...args: TArgs): TimerHandle;
/**
* Cancels a timer previously established by calling `setTimeout()`.
*
* Note: Passing an invalid handle silently does nothing; no exception is thrown.
*
* @param handle A value returned by `setTimeout()`.
*/
declare function clearTimeout(handle?: TimerHandle): void;
/**
* Decodes a string of data which has been encoded using Base64 encoding.
*
* @param encodedData is a binary string that contains Base64-encoded data.
* @returns A string that contains decoded data from encodedData.
*/
declare function atob(encodedData: string): string;
/**
* Creates a Base64-encoded ASCII string from a binary string.
*
* @param stringToEncode is a binary string to encode.
* @returns A string containing the Base64 representation of stringToEncode.
*/
declare function btoa(stringToEncode: string): string;
|