buddy

node MVC discord bot
Log | Files | Refs | README

index.d.ts (1786B)


      1 // Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>
      2 //                 Leon Yu <https://github.com/leonyu>
      3 //                 BendingBender <https://github.com/BendingBender>
      4 //                 Maple Miao <https://github.com/mapleeit>
      5 
      6 /// <reference types="node" />
      7 import * as stream from 'stream';
      8 import * as http from 'http';
      9 
     10 export = FormData;
     11 
     12 // Extracted because @types/node doesn't export interfaces.
     13 interface ReadableOptions {
     14   highWaterMark?: number;
     15   encoding?: string;
     16   objectMode?: boolean;
     17   read?(this: stream.Readable, size: number): void;
     18   destroy?(this: stream.Readable, error: Error | null, callback: (error: Error | null) => void): void;
     19   autoDestroy?: boolean;
     20 }
     21 
     22 interface Options extends ReadableOptions {
     23   writable?: boolean;
     24   readable?: boolean;
     25   dataSize?: number;
     26   maxDataSize?: number;
     27   pauseStreams?: boolean;
     28 }
     29 
     30 declare class FormData extends stream.Readable {
     31   constructor(options?: Options);
     32   append(key: string, value: any, options?: FormData.AppendOptions | string): void;
     33   getHeaders(userHeaders?: FormData.Headers): FormData.Headers;
     34   submit(
     35     params: string | FormData.SubmitOptions,
     36     callback?: (error: Error | null, response: http.IncomingMessage) => void
     37   ): http.ClientRequest;
     38   getBuffer(): Buffer;
     39   getBoundary(): string;
     40   getLength(callback: (err: Error | null, length: number) => void): void;
     41   getLengthSync(): number;
     42   hasKnownLength(): boolean;
     43 }
     44 
     45 declare namespace FormData {
     46   interface Headers {
     47     [key: string]: any;
     48   }
     49 
     50   interface AppendOptions {
     51     header?: string | Headers;
     52     knownLength?: number;
     53     filename?: string;
     54     filepath?: string;
     55     contentType?: string;
     56   }
     57 
     58   interface SubmitOptions extends http.RequestOptions {
     59     protocol?: 'https:' | 'http:';
     60   }
     61 }