Adding type defintion for murmurhash module of npm (#25413)

This commit is contained in:
Arne Schubert
2018-05-01 18:16:47 +02:00
committed by Andy
parent 349f349e9c
commit 5dafc2c0f6
4 changed files with 61 additions and 0 deletions

29
types/murmurhash/index.d.ts vendored Normal file
View File

@@ -0,0 +1,29 @@
// Type definitions for murmurhash 0.0
// Project: https://github.com/perezd/node-murmurhash
// Definitions by: Arne Schubert <https://github.com/atd-schubert>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = murmurhash;
/**
* JS Implementation of MurmurHash3 (r136) (as of May 20, 2011)
*
* @param key - ASCII only
* @param seed - Positive integer only
* @return - 32-bit positive integer hash
*/
declare function murmurhash(key: string, seed: number): number;
declare namespace murmurhash {
// Circular reference from murmurhash
function v3(key: string, seed: number): number;
/**
* JS Implementation of MurmurHash2
*
* @param str - ASCII only
* @param seed - Positive integer only
* @return - 32-bit positive integer hash
*/
function v2(str: string, seed: number): number;
}

View File

@@ -0,0 +1,8 @@
import murmurhash = require('murmurhash');
const stringValue = "test";
let numberValue = 123;
numberValue = murmurhash(stringValue, numberValue);
numberValue = murmurhash.v2(stringValue, numberValue);
numberValue = murmurhash.v3(stringValue, numberValue);

View File

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

View File

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