diff --git a/types/blob-util/blob-util-tests.ts b/types/blob-util/blob-util-tests.ts new file mode 100644 index 0000000000..af860a7ee1 --- /dev/null +++ b/types/blob-util/blob-util-tests.ts @@ -0,0 +1,17 @@ +import * as blobUtil from 'blob-util'; + +const testBlob = new Blob(['abcd']); + +blobUtil.base64StringToBlob('abcd'); // $ExpectType Promise +blobUtil.createObjectURL(testBlob); // $ExpectType string +blobUtil.imgSrcToBlob('test.jpg'); // $ExpectType Promise +blobUtil.createBlob(['abcd']); // $ExpectType Blob +blobUtil.arrayBufferToBlob(new ArrayBuffer(0)); // $ExpectType Promise +blobUtil.binaryStringToBlob('0101'); // $ExpectType Promise +blobUtil.blobToArrayBuffer(testBlob); // $ExpectType Promise +blobUtil.blobToBase64String(testBlob); // $ExpectType Promise +blobUtil.blobToBinaryString(testBlob); // $ExpectType Promise +blobUtil.canvasToBlob(new HTMLCanvasElement()); // $ExpectType Promise +blobUtil.dataURLToBlob('data:abcd'); // $ExpectType Promise +blobUtil.imgSrcToDataURL('test.jpg'); // $ExpectType Promise +blobUtil.revokeObjectURL('blob:example'); // $ExpectType void diff --git a/types/blob-util/index.d.ts b/types/blob-util/index.d.ts new file mode 100644 index 0000000000..ce99c3d893 --- /dev/null +++ b/types/blob-util/index.d.ts @@ -0,0 +1,19 @@ +// Type definitions for blob-util 1.2 +// Project: https://github.com/nolanlawson/blob-util#readme +// Definitions by: Max Battcher +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +export function createBlob(parts: any[], options?: { type: string }): Blob; +export function createObjectURL(blob: Blob): string; +export function revokeObjectURL(url: string): void; +export function blobToBinaryString(blob: Blob): Promise; +export function binaryStringToBlob(binary: string, type?: string): Promise; +export function blobToBase64String(blob: Blob): Promise; +export function base64StringToBlob(base64: string, type?: string): Promise; +export function dataURLToBlob(dataURL: string): Promise; +export function imgSrcToDataURL(src: string, type?: string, crossOrigin?: string): Promise; +export function canvasToBlob(canvas: HTMLCanvasElement, type?: string): Promise; +export function imgSrcToBlob(src: string, type?: string, crossOrigin?: string): Promise; +export function arrayBufferToBlob(arrayBuff: ArrayBuffer, type?: string): Promise; +export function blobToArrayBuffer(blob: Blob): Promise; diff --git a/types/blob-util/tsconfig.json b/types/blob-util/tsconfig.json new file mode 100644 index 0000000000..f34519775d --- /dev/null +++ b/types/blob-util/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "blob-util-tests.ts" + ] +} diff --git a/types/blob-util/tslint.json b/types/blob-util/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/blob-util/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }