mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
[@wordpress/blob] add new definitions (#36223)
This commit is contained in:
committed by
Daniel Rosenwasser
parent
3356f6955e
commit
95f3d2cc44
41
types/wordpress__blob/index.d.ts
vendored
Normal file
41
types/wordpress__blob/index.d.ts
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
// Type definitions for @wordpress/blob 2.4
|
||||
// Project: https://github.com/WordPress/gutenberg/tree/master/packages/blob/README.md
|
||||
// Definitions by: Derek Sifford <https://github.com/dsifford>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.5
|
||||
|
||||
/**
|
||||
* Create a blob URL from a file.
|
||||
*
|
||||
* @param file - The file to create a blob URL for.
|
||||
*
|
||||
* @returns The blob URL.
|
||||
*/
|
||||
export function createBlobURL(file: File): string;
|
||||
|
||||
/**
|
||||
* Retrieve a file based on a blob URL. The file must have been created by
|
||||
* `createBlobURL` and not removed by `revokeBlobURL`, otherwise it will return
|
||||
* `undefined`.
|
||||
*
|
||||
* @param url - The blob URL.
|
||||
*
|
||||
* @returns The file for the blob URL.
|
||||
*/
|
||||
export function getBlobByURL(url: string): File | undefined;
|
||||
|
||||
/**
|
||||
* Check whether a url is a blob url.
|
||||
*
|
||||
* @param url - The URL.
|
||||
*
|
||||
* @returns Is the url a blob url?
|
||||
*/
|
||||
export function isBlobURL(url: string): boolean;
|
||||
|
||||
/**
|
||||
* Remove the resource and file cache from memory.
|
||||
*
|
||||
* @param url - The blob URL.
|
||||
*/
|
||||
export function revokeBlobURL(url: string): void;
|
||||
19
types/wordpress__blob/tsconfig.json
Normal file
19
types/wordpress__blob/tsconfig.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["dom", "es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"paths": {
|
||||
"@wordpress/blob": ["wordpress__blob"]
|
||||
}
|
||||
},
|
||||
"files": ["index.d.ts", "wordpress__blob-tests.ts"]
|
||||
}
|
||||
1
types/wordpress__blob/tslint.json
Normal file
1
types/wordpress__blob/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
13
types/wordpress__blob/wordpress__blob-tests.ts
Normal file
13
types/wordpress__blob/wordpress__blob-tests.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import * as B from '@wordpress/blob';
|
||||
|
||||
B.createBlobURL(
|
||||
new File(['foo'], 'foo.txt', {
|
||||
type: 'text/plain',
|
||||
})
|
||||
);
|
||||
|
||||
B.getBlobByURL('blob:thisbitdoesnotmatter');
|
||||
|
||||
B.isBlobURL('blob:thisbitdoesnotmatter'); // true
|
||||
|
||||
B.revokeBlobURL('blob:thisbitdoesnotmatter');
|
||||
Reference in New Issue
Block a user