-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor TypeScript definition to CommonJS compatible export (#6)
- Loading branch information
1 parent
d5627c1
commit 61852f0
Showing
4 changed files
with
28 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,23 @@ | ||
/** | ||
[FNV-1a](https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function) non-cryptographic hash function. | ||
declare const fnv1a: { | ||
/** | ||
[FNV-1a](https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function) non-cryptographic hash function. | ||
@returns The hash as a positive integer. | ||
*/ | ||
export default function fnv1a(string: string): number; | ||
@returns The hash as a positive integer. | ||
@example | ||
``` | ||
import fnv1a = require('@sindresorhus/fnv1a'); | ||
fnv1a('🦄🌈'); | ||
//=> 582881315 | ||
``` | ||
*/ | ||
(string: string): number; | ||
|
||
// TODO: remove this in the next major version, refactor the whole definition to: | ||
// declare function fnv1a(string: string): number; | ||
// export = fnv1a; | ||
default: typeof fnv1a; | ||
}; | ||
|
||
export = fnv1a; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import {expectType} from 'tsd-check'; | ||
import fnv1a from '.'; | ||
import {expectType} from 'tsd'; | ||
import fnv1a = require('.'); | ||
|
||
expectType<number>(fnv1a('🦄🌈')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters