From a764d9b64ed2804e6ae6b3a9eaccb8f022238ea3 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sun, 22 Aug 2021 22:38:24 +0200 Subject: [PATCH] Require Node.js 12.20 and move to ESM --- .github/workflows/main.yml | 6 ++-- index.d.ts | 57 +++++++++++------------------ index.js | 60 +++++++++---------------------- index.test-d.ts | 6 ++-- license | 2 +- package.json | 18 +++++----- readme.md | 24 ++++++------- test.js | 74 +++++++++++++++++++------------------- 8 files changed, 99 insertions(+), 148 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c1870cf..441975c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,12 +10,10 @@ jobs: fail-fast: false matrix: node-version: - - 14 - - 12 - - 10 + - 16 steps: - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} - run: npm install diff --git a/index.d.ts b/index.d.ts index 598d94f..ac6b9bd 100644 --- a/index.d.ts +++ b/index.d.ts @@ -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; diff --git a/index.js b/index.js index 5705007..5c733a9 100644 --- a/index.js +++ b/index.js @@ -1,50 +1,25 @@ -'use strict'; - // FNV_PRIMES and FNV_OFFSETS from // http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-param const FNV_PRIMES = { - 32: 16777619n, - 64: 1099511628211n, - 128: 309485009821345068724781371n, - 256: 374144419156711147060143317175368453031918731002211n, - 512: 35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n, - 1024: 5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n + 32: 16_777_619n, + 64: 1_099_511_628_211n, + 128: 309_485_009_821_345_068_724_781_371n, + 256: 374_144_419_156_711_147_060_143_317_175_368_453_031_918_731_002_211n, + 512: 35_835_915_874_844_867_368_919_076_489_095_108_449_946_327_955_754_392_558_399_825_615_420_669_938_882_575_126_094_039_892_345_713_852_759n, + 1024: 5_016_456_510_113_118_655_434_598_811_035_278_955_030_765_345_404_790_744_303_017_523_831_112_055_108_147_451_509_157_692_220_295_382_716_162_651_878_526_895_249_385_292_291_816_524_375_083_746_691_371_804_094_271_873_160_484_737_966_720_260_389_217_684_476_157_468_082_573n, }; const FNV_OFFSETS = { - 32: 2166136261n, - 64: 14695981039346656037n, - 128: 144066263297769815596495629667062367629n, - 256: 100029257958052580907070968620625704837092796014241193945225284501741471925557n, - 512: 9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n, - 1024: 14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n + 32: 2_166_136_261n, + 64: 14_695_981_039_346_656_037n, + 128: 144_066_263_297_769_815_596_495_629_667_062_367_629n, + 256: 100_029_257_958_052_580_907_070_968_620_625_704_837_092_796_014_241_193_945_225_284_501_741_471_925_557n, + 512: 9_659_303_129_496_669_498_009_435_400_716_310_466_090_418_745_672_637_896_108_374_329_434_462_657_994_582_932_197_716_438_449_813_051_892_206_539_805_784_495_328_239_340_083_876_191_928_701_583_869_517_785n, + 1024: 14_197_795_064_947_621_068_722_070_641_403_218_320_880_622_795_441_933_960_878_474_914_617_582_723_252_296_732_303_717_722_150_864_096_521_202_355_549_365_628_174_669_108_571_814_760_471_015_076_148_029_755_969_804_077_320_157_692_458_563_003_215_304_957_150_157_403_644_460_363_550_505_412_711_285_966_361_610_267_868_082_893_823_963_790_439_336_411_086_884_584_107_735_010_676_915n, }; -// Legacy implementation for 32-bit + number types -function fnv1a(string) { - // Handle Unicode code points > 0x7f - let hash = Number(FNV_OFFSETS[32]); - let isUnicoded = false; - - for (let i = 0; i < string.length; i++) { - let characterCode = string.charCodeAt(i); - - // Non-ASCII characters trigger the Unicode escape logic - if (characterCode > 0x7F && !isUnicoded) { - string = unescape(encodeURIComponent(string)); - characterCode = string.charCodeAt(i); - isUnicoded = true; - } - - hash ^= characterCode; - hash += (hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24); - } - - return hash >>> 0; -} - -function bigInt(string, {size = 32} = {}) { +export default function fnv1a(string, {size = 32} = {}) { if (!FNV_PRIMES[size]) { throw new Error('The `size` option must be one of 32, 64, 128, 256, 512, or 1024'); } @@ -55,13 +30,13 @@ function bigInt(string, {size = 32} = {}) { // Handle Unicode code points > 0x7f let isUnicoded = false; - for (let i = 0; i < string.length; i++) { - let characterCode = string.charCodeAt(i); + for (let index = 0; index < string.length; index++) { + let characterCode = string.charCodeAt(index); // Non-ASCII characters trigger the Unicode escape logic if (characterCode > 0x7F && !isUnicoded) { string = unescape(encodeURIComponent(string)); - characterCode = string.charCodeAt(i); + characterCode = string.charCodeAt(index); isUnicoded = true; } @@ -71,6 +46,3 @@ function bigInt(string, {size = 32} = {}) { return hash; } - -module.exports = fnv1a; -module.exports.bigInt = bigInt; diff --git a/index.test-d.ts b/index.test-d.ts index cbf835b..b95b6ce 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -1,5 +1,5 @@ import {expectType} from 'tsd'; -import fnv1a = require('.'); +import fnv1a from './index.js'; -expectType(fnv1a('🦄🌈')); -expectType(fnv1a.bigInt('🦄🌈', {size: 128})); +expectType(fnv1a('🦄🌈')); +expectType(fnv1a('🦄🌈', {size: 128})); diff --git a/license b/license index e7af2f7..fa7ceba 100644 --- a/license +++ b/license @@ -1,6 +1,6 @@ MIT License -Copyright (c) Sindre Sorhus (sindresorhus.com) +Copyright (c) Sindre Sorhus (https://sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/package.json b/package.json index 9558a6d..95b11fb 100644 --- a/package.json +++ b/package.json @@ -4,13 +4,16 @@ "description": "FNV-1a non-cryptographic hash function", "license": "MIT", "repository": "sindresorhus/fnv1a", + "funding": "https://github.com/sponsors/sindresorhus", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" + "url": "https://sindresorhus.com" }, + "type": "module", + "exports": "./index.js", "engines": { - "node": ">=10" + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" }, "scripts": { "test": "xo && ava && tsd" @@ -38,13 +41,8 @@ "bigint" ], "devDependencies": { - "ava": "2.4.0", - "tsd": "0.11.0", - "xo": "0.25.3" - }, - "xo": { - "globals": [ - "BigInt" - ] + "ava": "3.15.0", + "tsd": "0.17.0", + "xo": "0.44.0" } } diff --git a/readme.md b/readme.md index 57bd3a9..5338cbc 100644 --- a/readme.md +++ b/readme.md @@ -15,27 +15,26 @@ $ npm install @sindresorhus/fnv1a ## Usage ```js -const fnv1a = require('@sindresorhus/fnv1a'); +import fnv1a from '@sindresorhus/fnv1a'; -fnv1a('🦄🌈'); -//=> 2868248295 +fnv1a('🦄🌈', {size: 32}); +//=> 2868248295n -fnv1a.bigInt('🦄🌈', {size: 128}); +fnv1a('🦄🌈', {size: 128}); //=> 13487074350300261116944693128525960095n + +Number(fnv1a('🦄🌈', {size: 32})); +//=> 2868248295 ``` ## API -### fnv1a(string) - -Returns the hash as a 32-bit positive integer. - -### fnv1a.bigInt(string, options?) - -Generate a larger hash using `BigInt`. +### fnv1a(string, options?) Returns the hash as a positive `BigInt`. +If you need it as a `number`, use `32` as `size` and wrap the return value in `Number(…)`. + #### options Type: `object` @@ -43,7 +42,8 @@ Type: `object` ##### size Type: `number`\ -Values: `32 | 64 | 128 | 256 | 512 | 1024` +Values: `32 | 64 | 128 | 256 | 512 | 1024`\ +Default: `32` The bit size of the hash. diff --git a/test.js b/test.js index 9ce2d93..3f2ab68 100644 --- a/test.js +++ b/test.js @@ -1,72 +1,72 @@ import test from 'ava'; -import fnv1a from '.'; +import fnv1a from './index.js'; test('default', t => { // Test 32-bit for various strings - t.is(fnv1a(''), 2166136261); - t.is(fnv1a('h'), 3977000791); - t.is(fnv1a('he'), 1547363254); - t.is(fnv1a('hel'), 179613742); - t.is(fnv1a('hell'), 477198310); - t.is(fnv1a('hello'), 1335831723); - t.is(fnv1a('hello '), 3801292497); - t.is(fnv1a('hello w'), 1402552146); - t.is(fnv1a('hello wo'), 3611200775); - t.is(fnv1a('hello wor'), 1282977583); - t.is(fnv1a('hello worl'), 2767971961); - t.is(fnv1a('hello world'), 3582672807); + t.is(fnv1a(''), 2_166_136_261n); + t.is(fnv1a('h'), 3_977_000_791n); + t.is(fnv1a('he'), 1_547_363_254n); + t.is(fnv1a('hel'), 179_613_742n); + t.is(fnv1a('hell'), 477_198_310n); + t.is(fnv1a('hello'), 1_335_831_723n); + t.is(fnv1a('hello '), 3_801_292_497n); + t.is(fnv1a('hello w'), 1_402_552_146n); + t.is(fnv1a('hello wo'), 3_611_200_775n); + t.is(fnv1a('hello wor'), 1_282_977_583n); + t.is(fnv1a('hello worl'), 2_767_971_961n); + t.is(fnv1a('hello world'), 3_582_672_807n); // Bigger test - t.is(fnv1a('Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium.'), 2964896417); + t.is(fnv1a('Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium.'), 2_964_896_417n); }); test('unicode handling', t => { // Verify Unicode handling against values from https://www.tools4noobs.com/online_tools/hash/ - t.is(fnv1a('🦄🌈'), 0xAAF5FEE7); - t.is(fnv1a('\u{0000}\u{0080}\u{0100}\u{0180}\u{0250}\u{02b0}\u{0300}\u{0370}\u{0400}\u{0500}\u{0530}\u{0590}\u{0600}\u{0700}\u{0780}\u{0900}\u{0980}\u{0a00}\u{0a80}\u{0b00}\u{0b80}\u{0c00}\u{0c80}\u{0d00}\u{0d80}\u{0e00}\u{0e80}\u{0f00}\u{1000}\u{10a0}\u{1100}\u{1200}\u{13a0}\u{1400}\u{1680}\u{16a0}\u{1700}\u{1720}\u{1740}\u{1760}\u{1780}\u{1800}\u{1900}\u{1950}\u{19e0}\u{1d00}\u{1e00}\u{1f00}\u{2000}\u{2070}\u{20a0}\u{20d0}\u{2100}\u{2150}\u{2190}\u{2200}\u{2300}\u{2400}\u{2440}\u{2460}\u{2500}\u{2580}\u{25a0}\u{2600}\u{2700}\u{27c0}\u{27f0}\u{2800}\u{2900}\u{2980}\u{2a00}\u{2b00}\u{2e80}\u{2f00}\u{2ff0}\u{3000}\u{3040}\u{30a0}\u{3100}\u{3130}\u{3190}\u{31a0}\u{31f0}\u{3200}\u{3300}\u{3400}\u{4dc0}\u{4e00}\u{a000}\u{a490}\u{ac00}\u{d800}\u{dc00}\u{e000}\u{f900}\u{fb00}\u{fb50}\u{fe00}\u{fe20}\u{fe30}\u{fe50}\u{fe70}\u{ff00}\u{fff0}\u{10000}\u{10080}\u{10100}\u{10300}\u{10330}\u{10380}\u{10400}\u{10450}\u{10480}\u{10800}\u{1d000}\u{1d100}\u{1d300}\u{1d400}\u{20000}\u{2f800}\u{e0000}\u{e0100}'), 0x983FDF05); + t.is(fnv1a('🦄🌈'), 0xAA_F5_FE_E7n); + t.is(fnv1a('\u{0000}\u{0080}\u{0100}\u{0180}\u{0250}\u{02B0}\u{0300}\u{0370}\u{0400}\u{0500}\u{0530}\u{0590}\u{0600}\u{0700}\u{0780}\u{0900}\u{0980}\u{0A00}\u{0A80}\u{0B00}\u{0B80}\u{0C00}\u{0C80}\u{0D00}\u{0D80}\u{0E00}\u{0E80}\u{0F00}\u{1000}\u{10A0}\u{1100}\u{1200}\u{13A0}\u{1400}\u{1680}\u{16A0}\u{1700}\u{1720}\u{1740}\u{1760}\u{1780}\u{1800}\u{1900}\u{1950}\u{19E0}\u{1D00}\u{1E00}\u{1F00}\u{2000}\u{2070}\u{20A0}\u{20D0}\u{2100}\u{2150}\u{2190}\u{2200}\u{2300}\u{2400}\u{2440}\u{2460}\u{2500}\u{2580}\u{25A0}\u{2600}\u{2700}\u{27C0}\u{27F0}\u{2800}\u{2900}\u{2980}\u{2A00}\u{2B00}\u{2E80}\u{2F00}\u{2FF0}\u{3000}\u{3040}\u{30A0}\u{3100}\u{3130}\u{3190}\u{31A0}\u{31F0}\u{3200}\u{3300}\u{3400}\u{4DC0}\u{4E00}\u{A000}\u{A490}\u{AC00}\u{D800}\u{DC00}\u{E000}\u{F900}\u{FB00}\u{FB50}\u{FE00}\u{FE20}\u{FE30}\u{FE50}\u{FE70}\u{FF00}\u{FFF0}\u{10000}\u{10080}\u{10100}\u{10300}\u{10330}\u{10380}\u{10400}\u{10450}\u{10480}\u{10800}\u{1D000}\u{1D100}\u{1D300}\u{1D400}\u{20000}\u{2F800}\u{E0000}\u{E0100}'), 0x98_3F_DF_05n); }); test('bigInt()', t => { // Sanity check larger hashes against values from // https://fnvhash.github.io/fnv-calculator-online/ - t.is(fnv1a.bigInt('hello world', {size: 32}), BigInt('0xd58b3fa7')); - t.is(fnv1a.bigInt('hello world', {size: 64}), BigInt('0x779a65e7023cd2e7')); - t.is(fnv1a.bigInt('hello world', {size: 128}), BigInt('0x6c155799fdc8eec4b91523808e7726b7')); - t.is(fnv1a.bigInt('hello world', {size: 256}), BigInt('0xecc3cf2e0edfccd3d87f21ec0883aad4db43eead66ce09eb4a97e04e1a184527')); - t.is(fnv1a.bigInt('hello world', {size: 512}), BigInt('0x2b9c19ec56ccf98da0f227cc82bfaacbd8350928bd2ceacae7bc8aa13e747f5c43ca4e2e98fc25e94e4e805675545ee95a3b968c0acfaecb90aea2fdbcd4de0f')); - t.is(fnv1a.bigInt('hello world', {size: 1024}), BigInt('0x3fa9d253e52ae80105b382c80a01e27a53d7bc1d201efb47b38f4d6e465489829d7d272127d20e1076129c00000000000000000000000000000000000000000000000000000000000000000000000000000253eb20f42a7228af9022d9f35ece5bb71e40fcd8717b80d164ab921709996e5c43aae801418e878cddf968d4616f')); + t.is(fnv1a('hello world', {size: 32}), BigInt('0xd58b3fa7')); + t.is(fnv1a('hello world', {size: 64}), BigInt('0x779a65e7023cd2e7')); + t.is(fnv1a('hello world', {size: 128}), BigInt('0x6c155799fdc8eec4b91523808e7726b7')); + t.is(fnv1a('hello world', {size: 256}), BigInt('0xecc3cf2e0edfccd3d87f21ec0883aad4db43eead66ce09eb4a97e04e1a184527')); + t.is(fnv1a('hello world', {size: 512}), BigInt('0x2b9c19ec56ccf98da0f227cc82bfaacbd8350928bd2ceacae7bc8aa13e747f5c43ca4e2e98fc25e94e4e805675545ee95a3b968c0acfaecb90aea2fdbcd4de0f')); + t.is(fnv1a('hello world', {size: 1024}), BigInt('0x3fa9d253e52ae80105b382c80a01e27a53d7bc1d201efb47b38f4d6e465489829d7d272127d20e1076129c00000000000000000000000000000000000000000000000000000000000000000000000000000253eb20f42a7228af9022d9f35ece5bb71e40fcd8717b80d164ab921709996e5c43aae801418e878cddf968d4616f')); }); test('bigInt() - 32-bit', t => { - t.is(fnv1a.bigInt('', {size: 32}), 2166136261n); - t.is(fnv1a.bigInt('hello', {size: 32}), 1335831723n); + t.is(fnv1a('', {size: 32}), 2_166_136_261n); + t.is(fnv1a('hello', {size: 32}), 1_335_831_723n); }); test('bigInt() - 64-bit', t => { - t.is(fnv1a.bigInt(''), 2166136261n); - t.is(fnv1a.bigInt('', {size: 64}), 14695981039346656037n); - t.is(fnv1a.bigInt('hello'), 1335831723n); - t.is(fnv1a.bigInt('hello', {size: 64}), 11831194018420276491n); - t.is(fnv1a.bigInt('🦄🌈'), 2868248295n); + t.is(fnv1a(''), 2_166_136_261n); + t.is(fnv1a('', {size: 64}), 14_695_981_039_346_656_037n); + t.is(fnv1a('hello'), 1_335_831_723n); + t.is(fnv1a('hello', {size: 64}), 11_831_194_018_420_276_491n); + t.is(fnv1a('🦄🌈'), 2_868_248_295n); }); test('bigInt() - 128-bit', t => { - t.is(fnv1a.bigInt('', {size: 128}), 144066263297769815596495629667062367629n); - t.is(fnv1a.bigInt('hello', {size: 128}), 302907886228425533802623465673358913971n); + t.is(fnv1a('', {size: 128}), 144_066_263_297_769_815_596_495_629_667_062_367_629n); + t.is(fnv1a('hello', {size: 128}), 302_907_886_228_425_533_802_623_465_673_358_913_971n); }); test('bigInt() - 256-bit', t => { - t.is(fnv1a.bigInt('', {size: 256}), 100029257958052580907070968620625704837092796014241193945225284501741471925557n); - t.is(fnv1a.bigInt('hello', {size: 256}), 24621739307028566391642840221992687346817534817626804975463790541119213691899n); + t.is(fnv1a('', {size: 256}), 100_029_257_958_052_580_907_070_968_620_625_704_837_092_796_014_241_193_945_225_284_501_741_471_925_557n); + t.is(fnv1a('hello', {size: 256}), 24_621_739_307_028_566_391_642_840_221_992_687_346_817_534_817_626_804_975_463_790_541_119_213_691_899n); }); test('bigInt() - 512-bit', t => { - t.is(fnv1a.bigInt('', {size: 512}), 9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n); - t.is(fnv1a.bigInt('hello', {size: 512}), 7892563648106928388641744747901962995816211260805030760135011933811709338702442123338016979459597105834714497783048560046644182143206509375819400532849111n); + t.is(fnv1a('', {size: 512}), 9_659_303_129_496_669_498_009_435_400_716_310_466_090_418_745_672_637_896_108_374_329_434_462_657_994_582_932_197_716_438_449_813_051_892_206_539_805_784_495_328_239_340_083_876_191_928_701_583_869_517_785n); + t.is(fnv1a('hello', {size: 512}), 7_892_563_648_106_928_388_641_744_747_901_962_995_816_211_260_805_030_760_135_011_933_811_709_338_702_442_123_338_016_979_459_597_105_834_714_497_783_048_560_046_644_182_143_206_509_375_819_400_532_849_111n); }); test('bigInt() - 1024-bit', t => { - t.is(fnv1a.bigInt('', {size: 1024}), 14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n); - t.is(fnv1a.bigInt('hello', {size: 1024}), 162599568807828018278740454090851618076261791243547429330845926617440124701815376483262958546407611470083720486420160817850263303428987405974668389046941240548898833919126704680456253506816487407186600714845619389901326326498663678676823405702541932736634507371229190999806123793839783784715844873833n); + t.is(fnv1a('', {size: 1024}), 14_197_795_064_947_621_068_722_070_641_403_218_320_880_622_795_441_933_960_878_474_914_617_582_723_252_296_732_303_717_722_150_864_096_521_202_355_549_365_628_174_669_108_571_814_760_471_015_076_148_029_755_969_804_077_320_157_692_458_563_003_215_304_957_150_157_403_644_460_363_550_505_412_711_285_966_361_610_267_868_082_893_823_963_790_439_336_411_086_884_584_107_735_010_676_915n); + t.is(fnv1a('hello', {size: 1024}), 162_599_568_807_828_018_278_740_454_090_851_618_076_261_791_243_547_429_330_845_926_617_440_124_701_815_376_483_262_958_546_407_611_470_083_720_486_420_160_817_850_263_303_428_987_405_974_668_389_046_941_240_548_898_833_919_126_704_680_456_253_506_816_487_407_186_600_714_845_619_389_901_326_326_498_663_678_676_823_405_702_541_932_736_634_507_371_229_190_999_806_123_793_839_783_784_715_844_873_833n); });