Skip to content

Commit 69fd4b2

Browse files
committed
Update package.json to include TypeScript definitions and ensure index.d.ts is part of the package files.
1 parent 3c50501 commit 69fd4b2

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

index.d.ts

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/// <reference types="node" />
2+
3+
export type BinaryLike = Buffer | ArrayBufferView;
4+
5+
export type DiffCallback = (err: Error | null, result?: Buffer) => void;
6+
export type StreamCallback = (err: Error | null, outPath?: string) => void;
7+
8+
export interface NativeAddon {
9+
diff(oldBuf: BinaryLike, newBuf: BinaryLike): Buffer;
10+
diff(oldBuf: BinaryLike, newBuf: BinaryLike, cb: DiffCallback): void;
11+
patch(oldBuf: BinaryLike, diffBuf: BinaryLike): Buffer;
12+
patch(oldBuf: BinaryLike, diffBuf: BinaryLike, cb: DiffCallback): void;
13+
diffStream(oldPath: string, newPath: string, outDiffPath: string): string;
14+
diffStream(
15+
oldPath: string,
16+
newPath: string,
17+
outDiffPath: string,
18+
cb: StreamCallback
19+
): void;
20+
patchStream(oldPath: string, diffPath: string, outNewPath: string): string;
21+
patchStream(
22+
oldPath: string,
23+
diffPath: string,
24+
outNewPath: string,
25+
cb: StreamCallback
26+
): void;
27+
}
28+
29+
export const native: NativeAddon;
30+
31+
export function diff(oldBuf: BinaryLike, newBuf: BinaryLike): Buffer;
32+
export function diff(
33+
oldBuf: BinaryLike,
34+
newBuf: BinaryLike,
35+
cb: DiffCallback
36+
): void;
37+
38+
export function patch(oldBuf: BinaryLike, diffBuf: BinaryLike): Buffer;
39+
export function patch(
40+
oldBuf: BinaryLike,
41+
diffBuf: BinaryLike,
42+
cb: DiffCallback
43+
): void;
44+
45+
export function diffStream(
46+
oldPath: string,
47+
newPath: string,
48+
outDiffPath: string
49+
): string;
50+
export function diffStream(
51+
oldPath: string,
52+
newPath: string,
53+
outDiffPath: string,
54+
cb: StreamCallback
55+
): void;
56+
57+
export function patchStream(
58+
oldPath: string,
59+
diffPath: string,
60+
outNewPath: string
61+
): string;
62+
export function patchStream(
63+
oldPath: string,
64+
diffPath: string,
65+
outNewPath: string,
66+
cb: StreamCallback
67+
): void;
68+
69+
declare const hdiffpatch: {
70+
native: NativeAddon;
71+
diff: typeof diff;
72+
patch: typeof patch;
73+
diffStream: typeof diffStream;
74+
patchStream: typeof patchStream;
75+
};
76+
77+
export default hdiffpatch;

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
"version": "1.1.2",
44
"description": "hdiffpatch port to node.js",
55
"main": "index.js",
6+
"types": "index.d.ts",
67
"bin": {
78
"hdp": "bin/hdiffpatch.js"
89
},
910
"files": [
1011
"index.js",
12+
"index.d.ts",
1113
"bin/",
1214
"prebuilds/"
1315
],

0 commit comments

Comments
 (0)