mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-02 14:38:20 +08:00
Adding type defintion for murmurhash module of npm (#25413)
This commit is contained in:
29
types/murmurhash/index.d.ts
vendored
Normal file
29
types/murmurhash/index.d.ts
vendored
Normal 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;
|
||||
}
|
||||
8
types/murmurhash/murmurhash-tests.ts
Normal file
8
types/murmurhash/murmurhash-tests.ts
Normal 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);
|
||||
23
types/murmurhash/tsconfig.json
Normal file
23
types/murmurhash/tsconfig.json
Normal 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"
|
||||
]
|
||||
}
|
||||
1
types/murmurhash/tslint.json
Normal file
1
types/murmurhash/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user