Added TypeScript declaration file

This commit is contained in:
Eddie Hedges 2018-09-18 18:14:51 -05:00
parent 2815920acf
commit f1f5d95e71
2 changed files with 24 additions and 0 deletions

23
index.d.ts vendored Normal file
View File

@ -0,0 +1,23 @@
declare module 'merkletreejs' {
interface IOptions {
isBitcoinTree: boolean
}
interface IProof {
position: 'left' | 'right'
data: Buffer
}
export default class MerkleTree {
getRoot: () => Buffer
getLeaves: () => Buffer[]
getLayers: () => Buffer[]
getProof: (leaf: Buffer, index?: number) => IProof[]
verify: (proof: IProof[], targetNode: Buffer, root: Buffer) => boolean
constructor(
leaves: Buffer[],
hashAlgorithm: (data: any) => Buffer,
options?: IOptions
)
}
}

View File

@ -3,6 +3,7 @@
"version": "0.0.10",
"description": "Construct Merkle Trees and verify proofs",
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"test": "tape test/*.js",
"docs:md": "node jsdoc.js"