diff --git a/types/is-png/index.d.ts b/types/is-png/index.d.ts new file mode 100644 index 0000000000..c2c74bab6d --- /dev/null +++ b/types/is-png/index.d.ts @@ -0,0 +1,16 @@ +// Type definitions for is-png 1.1 +// Project: https://github.com/sindresorhus/is-png#readme +// Definitions by: James Wild +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +/** + * Check whether a buffer contains a PNG image. + * @remarks This only performs a header check, and the buffer may not parse as a PNG file. + * @param buffer The buffer to check. + * @returns Whether the given buffer contains a PNG image. + */ +declare function isPng(buffer: Uint8Array | Buffer): boolean; + +export = isPng; diff --git a/types/is-png/is-png-tests.ts b/types/is-png/is-png-tests.ts new file mode 100644 index 0000000000..263560f855 --- /dev/null +++ b/types/is-png/is-png-tests.ts @@ -0,0 +1,7 @@ +import isPng = require("is-png"); + +const uint8Array = new Uint8Array(0); +isPng(uint8Array); // $ExpectType boolean + +const buffer = Buffer.from(uint8Array); +isPng(buffer); // $ExpectType boolean diff --git a/types/is-png/tsconfig.json b/types/is-png/tsconfig.json new file mode 100644 index 0000000000..0885bb6abe --- /dev/null +++ b/types/is-png/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", + "is-png-tests.ts" + ] +} diff --git a/types/is-png/tslint.json b/types/is-png/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/is-png/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }