Skip to content

Commit 0fa025e

Browse files
committed
improve(docs): add typescript typings
1 parent 3bfaf77 commit 0fa025e

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

index.d.ts

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/// <reference types="node" />
2+
3+
/**
4+
* Generate ssdeep hash asynchronously.
5+
* @param contents The data to hash.
6+
* @returns A promise to be resolved with the resulting hash.
7+
* @throws {TypeError} When the input is malformed.
8+
*/
9+
export declare function hash(contents: string | Buffer) : Promise<string>;
10+
11+
/**
12+
* Generate ssdeep hash synchronously.
13+
* @param contents The data to hash.
14+
* @returns The resulting hash.
15+
* @throws {TypeError} When the input is malformed.
16+
*/
17+
export declare function hashSync(contents: string | Buffer) : string;
18+
19+
/**
20+
* Compare ssdeep hashes asynchronously.
21+
* @param hash1 The first hash to compare.
22+
* @param hash2 The second hash to compare.
23+
* @returns A promise to be resolved with the similarity score for the input hashes, between 0-100.
24+
* @throws {TypeError} When the hashes are malformed.
25+
*/
26+
export declare function compare(hash1: string, hash2: string): Promise<number>;
27+
28+
/**
29+
* Compare ssdeep hashes synchronously.
30+
* @param hash1 The first hash to compare.
31+
* @param hash2 The second hash to compare.
32+
* @returns The similarity score for the input hashes, between 0-100.
33+
* @throws {TypeError} When the hashes are malformed.
34+
*/
35+
export declare function compareSync(hash1: string, hash2: string): number;

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"name": "fast-ssdeep",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "Node.js binding for the ssdeep CTPH library",
55
"main": "index.js",
6+
"types": "index.d.ts",
67
"engines": {
78
"node": ">= 10.0.0"
89
},
@@ -20,6 +21,7 @@
2021
"ssdeep/edit_dist.h",
2122
"ssdeep/sum_table.h",
2223
"index.js",
24+
"index.d.ts",
2325
"binding.gyp"
2426
],
2527
"repository": {

test/ssdeep_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const assert = require("assert");
22
const { describe, it } = require("mocha");
3-
const ssdeep = require('bindings')('fast-ssdeep.node');
3+
const ssdeep = require("../");
44

55
describe("should generate correct hashes", function(){
66
const hashes = {

0 commit comments

Comments
 (0)