Merge pull request #31345 from BendingBender/base64-async

Add types for base64-async
This commit is contained in:
Nathan Shively-Sanders
2018-12-17 10:20:36 -08:00
committed by GitHub
4 changed files with 68 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
import b64 = require('base64-async');
import * as fs from 'fs';
const buffer: Buffer = fs.readFileSync('somehugefile.jpg');
const b64String = 'aGkgbXVt...';
b64.encode(buffer).then(b64String => {
b64String; // $ExpectType string
});
b64.encode(buffer, { chunkSize: 10 }).then(b64String => {
b64String; // $ExpectType string
});
b64.decode(b64String).then(buffer => {
buffer; // $ExpectType Buffer
});
b64.decode(b64String, { chunkSize: 10 }).then(buffer => {
buffer; // $ExpectType Buffer
});
b64(buffer); // $ExpectType Promise<string>
b64(buffer, { chunkSize: 10 }); // $ExpectType Promise<string>
b64(b64String); // $ExpectType Promise<Buffer>
b64(b64String, { chunkSize: 10 }); // $ExpectType Promise<Buffer>
+20
View File
@@ -0,0 +1,20 @@
// Type definitions for base64-async 2.1
// Project: https://github.com/lukechilds/base64-async
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
export = base64Async;
declare function base64Async(input: Buffer, options?: base64Async.Options): Promise<string>;
declare function base64Async(input: string, options?: base64Async.Options): Promise<Buffer>;
declare namespace base64Async {
function encode(input: Buffer, options?: Options): Promise<string>;
function decode(input: string, options?: Options): Promise<Buffer>;
interface Options {
chunkSize?: number;
}
}
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"base64-async-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }