diff --git a/types/base64-async/base64-async-tests.ts b/types/base64-async/base64-async-tests.ts new file mode 100644 index 0000000000..7efe30b89f --- /dev/null +++ b/types/base64-async/base64-async-tests.ts @@ -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 +b64(buffer, { chunkSize: 10 }); // $ExpectType Promise +b64(b64String); // $ExpectType Promise +b64(b64String, { chunkSize: 10 }); // $ExpectType Promise diff --git a/types/base64-async/index.d.ts b/types/base64-async/index.d.ts new file mode 100644 index 0000000000..d14125a3ca --- /dev/null +++ b/types/base64-async/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for base64-async 2.1 +// Project: https://github.com/lukechilds/base64-async +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export = base64Async; + +declare function base64Async(input: Buffer, options?: base64Async.Options): Promise; +declare function base64Async(input: string, options?: base64Async.Options): Promise; + +declare namespace base64Async { + function encode(input: Buffer, options?: Options): Promise; + function decode(input: string, options?: Options): Promise; + + interface Options { + chunkSize?: number; + } +} diff --git a/types/base64-async/tsconfig.json b/types/base64-async/tsconfig.json new file mode 100644 index 0000000000..38a35f20b8 --- /dev/null +++ b/types/base64-async/tsconfig.json @@ -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" + ] +} diff --git a/types/base64-async/tslint.json b/types/base64-async/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/base64-async/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }