<commit_before>﻿declare module "http" {
    import image = require("image-source");
    import promises = require("promises");

    /**
    * Downloads the content from the specified URL as a string.
    * @param url The URL to request from.
    */
    function getString(url: string): promises.Promise<string>

    /**
    * Downloads the content from the specified URL as a string.
    * @param options An object that specifies various request options.
    */
    function getString(options: HttpRequestOptions): promises.Promise<string>

    /**
    * Downloads the content from the specified URL as a string and returns its JSON.parse representation.
    * @param url The URL to request from.
    */
    function getJSON<T>(url: string): promises.Promise<T>

    /**
    * Downloads the content from the specified URL as a string and returns its JSON.parse representation.
    * @param options An object that specifies various request options.
    */
    function getJSON<T>(options: HttpRequestOptions): promises.Promise<T>

    /**
    * Downloads the content from the specified URL and attempts to decode it as an image.
    * @param url The URL to request from.
    */
    function getImage(url: string): promises.Promise<image.ImageSource>

    /**
    * Downloads the content from the specified URL and attempts to decode it as an image.
    * @param options An object that specifies various request options.
    */
    function getImage(options: HttpRequestOptions): promises.Promise<image.ImageSource>

    /**
    * Makes a generic http request using the provided options and returns a HttpResponse Object.
    * @param options An object that specifies various request options.
    */
    function request(options: HttpRequestOptions): promises.Promise<HttpResponse>;

    interface HttpRequestOptions {
        url: string;
        method: string;
        headers?: any;
        content?: any;
        timeout?: number;
    }

    interface HttpResponse {
        statusCode: number;
        headers: any;
        content?: HttpContent;
    }

    interface HttpContent {
        raw: any;
        toString: () => string;
        // TODO: Isn't parseJSON better naming? toJSON sounds to me like we will return a string object
        toJSON: () => any;
        toImage: () => image.ImageSource;
    }
}<commit_msg>comments added<commit_after>﻿declare module "http" {
    import image = require("image-source");
    import promises = require("promises");

    /**
    * Downloads the content from the specified URL as a string.
    * @param url The URL to request from.
    */
    function getString(url: string): promises.Promise<string>

    /**
    * Downloads the content from the specified URL as a string.
    * @param options An object that specifies various request options.
    */
    function getString(options: HttpRequestOptions): promises.Promise<string>

    /**
    * Downloads the content from the specified URL as a string and returns its JSON.parse representation.
    * @param url The URL to request from.
    */
    function getJSON<T>(url: string): promises.Promise<T>

    /**
    * Downloads the content from the specified URL as a string and returns its JSON.parse representation.
    * @param options An object that specifies various request options.
    */
    function getJSON<T>(options: HttpRequestOptions): promises.Promise<T>

    /**
    * Downloads the content from the specified URL and attempts to decode it as an image.
    * @param url The URL to request from.
    */
    function getImage(url: string): promises.Promise<image.ImageSource>

    /**
    * Downloads the content from the specified URL and attempts to decode it as an image.
    * @param options An object that specifies various request options.
    */
    function getImage(options: HttpRequestOptions): promises.Promise<image.ImageSource>

    /**
    * Makes a generic http request using the provided options and returns a HttpResponse Object.
    * @param options An object that specifies various request options.
    */
    function request(options: HttpRequestOptions): promises.Promise<HttpResponse>;

    interface HttpRequestOptions {
        /**
          * Gets or sets the request url.
          */
        url: string;

        /**
          * Gets or sets the request method.
          */
        method: string;

        /**
          * Gets or sets the request headers in JSON format.
          */
        headers?: any;

        /**
          * Gets or sets the request body.
          */
        content?: any;

        /**
          * Gets or sets the request timeout.
          */
        timeout?: number;
    }

    interface HttpResponse {
        /**
          * Gets the response status code.
          */
        statusCode: number;

        /**
          * Gets the response headers.
          */
        headers: any;

        /**
          * Gets the response content.
          */
        content?: HttpContent;
    }

    interface HttpContent {
        /**
          * Gets the response body as raw data.
          */
        raw: any;

        /**
          * Gets the response body as string.
          */
        toString: () => string;

        /**
          * Gets the response body as JSON object.
          */
        toJSON: () => any;

        /**
          * Gets the response body as ImageSource.
          */
        toImage: () => image.ImageSource;
    }
}
{'fraction_non_alphanumeric': 0.0888109305760709, 'fraction_numerical': 0.0, 'mean_word_length': 2.228247914183552, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3656814', 'n_tokens_mistral': 1358, 'n_tokens_neox': 1313, 'n_words': 525}