From ccaa6b01b5acf1313c3de0bc09d924d930cf5f7e Mon Sep 17 00:00:00 2001 From: "leo.lambert02@gmail.com" Date: Sat, 5 Feb 2022 19:01:11 +0100 Subject: [PATCH 1/2] Added types --- index.d.ts | 19 +++++++++++++++++++ package.json | 5 +++-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..732bc9a --- /dev/null +++ b/index.d.ts @@ -0,0 +1,19 @@ +declare module "fpcalc" { + export interface FpcalcOptions { + length?: number + raw?: boolean + command?: string + } + + export interface FpcalcResult { + file?: string + duration?: number + fingerprint: T + } + + function fpcalc(file: string | ReadableStream, callback: (err: Error, result: FpcalcResult) => void) + function fpcalc(file: string | ReadableStream, options: FpcalcOptions & { raw: true }, callback: (err: Error, result: FpcalcResult) => void) + function fpcalc(file: string | ReadableStream, options: FpcalcOptions & { raw: false }, callback: (err: Error, result: FpcalcResult) => void) + + export default fpcalc +} \ No newline at end of file diff --git a/package.json b/package.json index 8c1ec16..a5a6058 100644 --- a/package.json +++ b/package.json @@ -31,5 +31,6 @@ }, "devDependencies": { "tape": "^4.2.1" - } -} + }, + "types": "index.d.ts" +} \ No newline at end of file From 7598ad5aac0600897c2db207adb6af5306d2ce45 Mon Sep 17 00:00:00 2001 From: "leo.lambert02@gmail.com" Date: Sat, 5 Feb 2022 19:21:28 +0100 Subject: [PATCH 2/2] Fixed a bug un function signature You couldn't use options without setting the raw field --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 732bc9a..3a188b4 100644 --- a/index.d.ts +++ b/index.d.ts @@ -13,7 +13,7 @@ declare module "fpcalc" { function fpcalc(file: string | ReadableStream, callback: (err: Error, result: FpcalcResult) => void) function fpcalc(file: string | ReadableStream, options: FpcalcOptions & { raw: true }, callback: (err: Error, result: FpcalcResult) => void) - function fpcalc(file: string | ReadableStream, options: FpcalcOptions & { raw: false }, callback: (err: Error, result: FpcalcResult) => void) + function fpcalc(file: string | ReadableStream, options: FpcalcOptions, callback: (err: Error, result: FpcalcResult) => void) export default fpcalc } \ No newline at end of file