diff --git a/types/buffer-from/buffer-from-tests.ts b/types/buffer-from/buffer-from-tests.ts new file mode 100644 index 0000000000..8fdd4fa811 --- /dev/null +++ b/types/buffer-from/buffer-from-tests.ts @@ -0,0 +1,6 @@ +import bufferFrom = require('buffer-from'); + +bufferFrom([1, 2, 3, 4]); // $ExpectType Buffer +bufferFrom(new Uint8Array([1, 2, 3, 4]).buffer, 1, 2); // $ExpectType Buffer +bufferFrom('test', 'utf8'); // $ExpectType Buffer +bufferFrom(bufferFrom('test')); // $ExpectType Buffer diff --git a/types/buffer-from/index.d.ts b/types/buffer-from/index.d.ts new file mode 100644 index 0000000000..412056ed8a --- /dev/null +++ b/types/buffer-from/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for buffer-from 1.1 +// Project: https://github.com/LinusU/buffer-from#readme +// Definitions by: Nat Burns +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare function bufferFrom(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer; +declare function bufferFrom(str: string, encoding?: string): Buffer; +declare function bufferFrom(data: ReadonlyArray | Buffer): Buffer; + +export = bufferFrom; diff --git a/types/buffer-from/tsconfig.json b/types/buffer-from/tsconfig.json new file mode 100644 index 0000000000..195d0a78b6 --- /dev/null +++ b/types/buffer-from/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", + "buffer-from-tests.ts" + ] +} diff --git a/types/buffer-from/tslint.json b/types/buffer-from/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/buffer-from/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }