@types/data-urls
TypeScript definitions for data-urls
Last updated 9 months ago by types .
MIT · Repository · Original npm · Tarball · package.json
$ npm install @types/data-urls 
SYNC missed versions from official npm registry.

Installation

npm install --save @types/data-urls

Summary

This package contains type definitions for data-urls (https://github.com/jsdom/data-urls#readme).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/data-urls.

index.d.ts

import MIMEType = require("whatwg-mimetype");
import { URLRecord } from "whatwg-url";

/**
 * Parses `data:` URLs.
 *
 * @param stringInput The `data:` URL to parse.
 * @returns The parsed data URL, or `null` if the result cannot be parsed as a `data:` URL.
 *
 * @example
 * import parseDataURL = require("data-urls");
 *
 * const textExample = parseDataURL("data:,Hello%2C%20World!");
 * console.log(textExample.mimeType.toString()); // "text/plain;charset=US-ASCII"
 * console.log(textExample.body);                // Uint8Array(13) [ 72, 101, 108, 108, 111, 44, … ]
 *
 * const htmlExample = parseDataURL("data:text/html,%3Ch1%3EHello%2C%20World!%3C%2Fh1%3E");
 * console.log(htmlExample.mimeType.toString()); // "text/html"
 * console.log(htmlExample.body);                // Uint8Array(22) [ 60, 104, 49, 62, 72, 101, … ]
 *
 * const pngExample = parseDataURL("data:image/png;base64,iVBORw0KGgoAAA" +
 *                                 "ANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4" +
 *                                 "//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU" +
 *                                 "5ErkJggg==");
 * console.log(pngExample.mimeType.toString()); // "image/png"
 * console.log(pngExample.body);                // Uint8Array(85) [ 137, 80, 78, 71, 13, 10, … ]
 */
declare function parseDataURL(stringInput: string): parseDataURL.DataURL | null;

declare namespace parseDataURL {
    interface DataURL {
        mimeType: MIMEType;
        body: Uint8Array;
    }

    /**
     * If you are using the [whatwg-url](https://github.com/jsdom/whatwg-url) package, you may already have a
     * "URL record" object on hand, as produced by that package's `parseURL` export. In that case, you can use
     * this function to save a bit of work.
     *
     * @example
     * import { parseURL } from "whatwg-url";
     * const dataURLFromURLRecord = require("data-urls").fromURLRecord;
     *
     * const urlRecord = parseURL("data:,Hello%2C%20World!");
     * const dataURL = dataURLFromURLRecord(urlRecord);
     */
    function fromURLRecord(urlRecord: URLRecord): DataURL | null;
}

export = parseDataURL;

Additional Details

Credits

These definitions were written by Jaime Filho, and BendingBender.

Current Tags

  • 3.0.5                                ...           latest (9 months ago)
  • 2.0.0                                ...           ts3.2 (6 years ago)
  • 2.0.0                                ...           ts3.3 (6 years ago)
  • 2.0.0                                ...           ts3.4 (6 years ago)
  • 2.0.0                                ...           ts3.5 (6 years ago)
  • 2.0.1                                ...           ts3.6 (6 years ago)
  • 2.0.1                                ...           ts3.7 (6 years ago)
  • 2.0.1                                ...           ts3.8 (6 years ago)
  • 2.0.1                                ...           ts3.9 (6 years ago)
  • 3.0.0                                ...           ts4.0 (4 years ago)
  • 3.0.1                                ...           ts4.1 (4 years ago)
  • 3.0.1                                ...           ts4.2 (4 years ago)
  • 3.0.1                                ...           ts4.3 (4 years ago)
  • 3.0.1                                ...           ts4.4 (4 years ago)
  • 3.0.4                                ...           ts4.5 (3 years ago)
  • 3.0.4                                ...           ts4.6 (3 years ago)
  • 3.0.4                                ...           ts4.7 (3 years ago)
  • 3.0.4                                ...           ts4.8 (3 years ago)
  • 3.0.4                                ...           ts4.9 (3 years ago)
  • 3.0.4                                ...           ts5.0 (3 years ago)
  • 3.0.4                                ...           ts5.1 (3 years ago)
  • 3.0.5                                ...           ts5.2 (9 months ago)
  • 3.0.5                                ...           ts5.3 (9 months ago)
  • 3.0.5                                ...           ts5.4 (9 months ago)
  • 3.0.5                                ...           ts5.5 (9 months ago)
  • 3.0.5                                ...           ts5.6 (9 months ago)
  • 3.0.5                                ...           ts5.7 (9 months ago)
  • 3.0.5                                ...           ts5.8 (9 months ago)
  • 3.0.5                                ...           ts5.9 (9 months ago)
  • 3.0.5                                ...           ts6.0 (9 months ago)
  • 3.0.5                                ...           ts7.0 (9 months ago)
  • 3.0.5                                ...           ts7.1 (9 months ago)

8 Versions

  • 3.0.5                                ...           9 months ago
  • 3.0.3                                ...           3 years ago
  • 3.0.2                                ...           3 years ago
  • 3.0.1                                ...           4 years ago
  • 3.0.4                                ...           3 years ago
  • 3.0.0                                ...           4 years ago
  • 2.0.1                                ...           6 years ago
  • 2.0.0                                ...           6 years ago
Maintainers (1)
Downloads
Total 18
Today 0
This Week 1
This Month 17
Last Day 0
Last Week 8
Last Month 1
Dependencies (2)
Dev Dependencies (0)
None
Dependents (0)
None

© 2010 - cnpmjs.org x YWFE | Home | YWFE