diff --git a/types/hapi__b64/hapi__b64-tests.ts b/types/hapi__b64/hapi__b64-tests.ts new file mode 100644 index 0000000000..699fc2c65d --- /dev/null +++ b/types/hapi__b64/hapi__b64-tests.ts @@ -0,0 +1,17 @@ +import * as B64 from '@hapi/b64'; +import * as fs from 'fs'; + +const stream = fs.createReadStream('package.json'); +const encoder = new B64.Encoder(); +const decoder = new B64.Decoder(); + +stream.pipe(encoder).pipe(process.stdout); +stream.pipe(decoder).pipe(process.stdout); + +B64.decode(Buffer.from('aHR0cHM6Ly9naXRodWIuY29t')); // $ExpectType Buffer +B64.encode(Buffer.from('https://github.com')); // $ExpectType Buffer + +B64.base64urlDecode('aHR0cHM6Ly9naXRodWIuY29t'); // $ExpectType string +B64.base64urlDecode('aHR0cHM6Ly9naXRodWIuY29t', 'ascii'); // $ExpectType string +B64.base64urlDecode('aHR0cHM6Ly9naXRodWIuY29t', 'buffer'); // $ExpectType Buffer +B64.base64urlEncode('https://github.com'); // $ExpectType string diff --git a/types/hapi__b64/index.d.ts b/types/hapi__b64/index.d.ts new file mode 100644 index 0000000000..8a4a0fd696 --- /dev/null +++ b/types/hapi__b64/index.d.ts @@ -0,0 +1,19 @@ +// Type definitions for @hapi/b64 5.0 +// Project: https://github.com/hapijs/b64#readme +// Definitions by: Florian Keller +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import * as stream from 'stream'; + +export class Decoder extends stream.Transform {} +export class Encoder extends stream.Transform {} + +export function decode(buffer: Buffer): Buffer; +export function encode(buffer: Buffer): Buffer; + +export function base64urlEncode(value: string | Buffer, encoding?: BufferEncoding): string; + +export function base64urlDecode(value: string, encoding?: BufferEncoding): string; +export function base64urlDecode(value: string, encoding: 'buffer'): Buffer; diff --git a/types/hapi__b64/tsconfig.json b/types/hapi__b64/tsconfig.json new file mode 100644 index 0000000000..d6437d400e --- /dev/null +++ b/types/hapi__b64/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "paths": { + "@hapi/b64": [ + "hapi__b64" + ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "hapi__b64-tests.ts" + ] +} diff --git a/types/hapi__b64/tslint.json b/types/hapi__b64/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/hapi__b64/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }