Add typings for checksum-0.1.1.

This commit is contained in:
Rogier Schouten
2014-10-22 10:21:24 +02:00
parent bd9a1922e4
commit 600e24f64f
3 changed files with 59 additions and 0 deletions
+1
View File
@@ -51,6 +51,7 @@ All definitions files include a header with the author and editors, so at some p
* [bunyan](https://github.com/trentm/node-bunyan) (by [Alex Mikhalev](https://github.com/amikhalev))
* [CasperJS](http://casperjs.org) (by [Jed Mao](https://github.com/jedmao))
* [CanvasJS](http://canvasjs.com) (by [Mark Overholt](https://github.com/mover5))
* [checksum](https://github.com/dshaw/checksum) (by [Rogier Schouten](https://github.com/rogierschouten))
* [Cheerio](https://github.com/MatthewMueller/cheerio) (by [Bret Little](https://github.com/blittle))
* [Chosen](http://harvesthq.github.com/chosen/) (by [Boris Yankov](https://github.com/borisyankov))
* [Chroma.js](https://github.com/gka/chroma.js) (by [Sebastian Brückner](https://github.com/invliD))
+14
View File
@@ -0,0 +1,14 @@
/// <reference path="checksum.d.ts" />
import checksum = require("checksum");
var s: string = checksum("abcd");
var t: string = checksum("abcd", { algorithm: 'sha1' });
checksum.file("myfile.txt", (error: Error, hash: string): void => {
// do nothing
});
checksum.file("myfile.txt", { algorithm: 'sha1' }, (error: Error, hash: string): void => {
// do nothing
});
+44
View File
@@ -0,0 +1,44 @@
// Type definitions for checksum 0.1.1
// Project: https://github.com/dshaw/checksum
// Definitions by: Rogier Schouten <https://github.com/rogierschouten>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "checksum" {
module checksum {
/**
* Options object for all functions
*/
interface ChecksumOptions {
/**
* Algorithm to use, default 'sha1'
* Can be 'sha1' or 'md5' (see module 'crypto').
*/
algorithm?: string;
}
/**
* Generate the checksum for a file on disk
* @param filename The file name
* @param callback Callback which is called with the result or an error
*/
function file(filename: string, callback: (error: Error, hash: string) => void): void;
/**
* Generate the checksum for a file on disk
* @param filename The file name
* @param options Options object to indicate hash algo
* @param callback Callback which is called with the result or an error
*/
function file(filename: string, options: ChecksumOptions, callback: (error: Error, hash: string) => void): void;
}
/**
* Generates a checksum for the given value
* @param value Any value
* @param options Allows to set the algorithm
* @returns Checksum
*/
function checksum(value: any, options?: checksum.ChecksumOptions): string;
export = checksum;
}