imghash
imghash copied to clipboard
TypeScript support
Any plans for the TypeScript support?
I've quickly mocked something like this:
// index.d.ts
/// <reference types="node" />
// fs filepath: PathLike | number;
// type PathLike = string | Buffer | URL;
type Filepath = string | Buffer;
type Format = "hex" | "binary";
// blockhash ImageData
type Data = {
width: number;
height: number;
data: Uint8Array | Uint8ClampedArray | number[];
};
export declare function hash(filepath: Filepath, bits?: number, format?: Format): Promise<string>;
export declare function hashRaw(data: Data, bits: number): string;
export declare function hexToBinary(s: string): string;
export declare function binaryToHex(s: string): string;
I've also noticed that the lookup has mixed string | number
keys:
https://github.com/pwlmaciejewski/imghash/blob/master/index.js#L100
Is that intended?
Tbh it is infering nicely most of the stuff from the dependencies, tho no direct typings therefore TS complains about lack of them.
@Eghizio Thank you 🙏
Is that intended?
I think that's prettier's doing 😬 Is this causing any trouble?
no direct typings therefore TS complains about lack of them.
Can you push a PR? I would love to rewrite the whole thing to TS but for now the manual typing should do.
No problem. No it is not causing any problems. I'll try to do it as soon as I can ;)