Merge pull request #19124 from BendingBender/unique-hash-stream

[unique-hash-stream] add typings
This commit is contained in:
Daniel Rosenwasser
2017-08-18 13:10:18 -07:00
committed by GitHub
4 changed files with 51 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
// Type definitions for unique-hash-stream 1.0
// Project: https://github.com/stream-utils/unique-hash-stream
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import { Transform } from 'stream';
export = UniqueFactory;
declare function UniqueFactory(hashingFn?: (doc: any) => string): Transform;
declare namespace UniqueFactory {
const Unique: typeof Transform;
function calculate(doc: any): string;
}
+22
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",
"unique-hash-stream-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -0,0 +1,12 @@
import unique = require('unique-hash-stream');
const stream = unique();
unique(doc => {
doc; // $ExpectType any
return 'foo';
});
stream; // $ExpectType Transform
unique.Unique; // $ExpectType typeof Transform
unique.calculate; // $ExpectType (doc: any) => string
stream instanceof unique.Unique;