-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Require Node.js 12.20 and move to ESM
- Loading branch information
1 parent
03fe6a4
commit a764d9b
Showing
8 changed files
with
99 additions
and
148 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
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,46 +1,29 @@ | ||
declare namespace fnv1a { | ||
interface Options { | ||
/** | ||
The bit size of the hash. | ||
@default 32 | ||
*/ | ||
size?: 32 | 64 | 128 | 256 | 512 | 1024; | ||
} | ||
} | ||
|
||
declare const fnv1a: { | ||
export interface Options { | ||
/** | ||
[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. | ||
The bit size of the hash. | ||
@example | ||
``` | ||
import fnv1a = require('@sindresorhus/fnv1a'); | ||
fnv1a('π¦π'); | ||
//=> 2868248295 | ||
``` | ||
@default 32 | ||
*/ | ||
(string: string): number; | ||
readonly size?: 32 | 64 | 128 | 256 | 512 | 1024; | ||
} | ||
|
||
/** | ||
[FNV-1a](https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function) non-cryptographic hash function. | ||
/** | ||
[FNV-1a](https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function) non-cryptographic hash function. | ||
Generate a larger hash using `BigInt`. | ||
@returns The hash as a positive `BigInt`. | ||
@returns The hash as a positive BigInt. | ||
@example | ||
``` | ||
import fnv1a from '@sindresorhus/fnv1a'; | ||
@example | ||
``` | ||
import fnv1a = require('@sindresorhus/fnv1a'); | ||
fnv1a('π¦π', {size: 32}); | ||
//=> 2868248295n | ||
fnv1a.bigInt('π¦π', {size: 128}); | ||
//=> 13487074350300261116944693128525960095n | ||
``` | ||
*/ | ||
bigInt(string: string, options?: fnv1a.Options): bigint; | ||
}; | ||
fnv1a('π¦π', {size: 128}); | ||
//=> 13487074350300261116944693128525960095n | ||
export = fnv1a; | ||
Number(fnv1a('π¦π', {size: 32})); | ||
//=> 2868248295 | ||
``` | ||
*/ | ||
export default function fnv1a(string: string, options?: Options): bigint; |
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,5 +1,5 @@ | ||
import {expectType} from 'tsd'; | ||
import fnv1a = require('.'); | ||
import fnv1a from './index.js'; | ||
|
||
expectType<number>(fnv1a('π¦π')); | ||
expectType<bigint>(fnv1a.bigInt('π¦π', {size: 128})); | ||
expectType<bigint>(fnv1a('π¦π')); | ||
expectType<bigint>(fnv1a('π¦π', {size: 128})); |
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
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
Oops, something went wrong.