[check-sum] add typings

This commit is contained in:
Dimitri Benin 2017-08-18 10:29:20 +02:00
parent 7ad5650b35
commit 4b9d24bceb
4 changed files with 65 additions and 0 deletions

View File

@ -0,0 +1,18 @@
import checksum = require('check-sum');
import * as fs from 'fs';
const stream = fs.createReadStream('package.json');
checksum(stream, {
md5: 'asdfasdfasdf',
sha1: 'asdfasdfasdf'
}, err => {
err; // $ExpectType any
});
checksum('package.json', {
md5: 'asdfasdfasdf',
sha1: 'asdfasdfasdf'
}, err => {
err; // $ExpectType Error | ChecksumError | undefined
});

24
types/check-sum/index.d.ts vendored Normal file
View File

@ -0,0 +1,24 @@
// Type definitions for check-sum 0.1
// Project: https://github.com/stream-utils/check-sum
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import { Readable } from 'stream';
export = checksum;
declare function checksum(stream: Readable, hashes: checksum.Hashes, callback: (error: checksum.ChecksumError | any) => void): (fn: () => void) => void;
declare function checksum(path: string, hashes: checksum.Hashes, callback: (error: checksum.ChecksumError | Error | undefined) => void): (fn: () => void) => void;
declare namespace checksum {
interface ChecksumError {
algorithm: string;
expected: string;
actual: string;
}
interface Hashes {
[algorithm: string]: string | Buffer;
}
}

View File

@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"check-sum-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }