From ff5740c0d2574cd691a19549b83a60f9839150b3 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Sat, 27 Apr 2024 19:02:20 +0000 Subject: [PATCH 1/2] fix: remove `hyperdyperid` dependency --- package.json | 4 +--- src/buffers/utf8/CachedUtf8Decoder.ts | 9 ++++++++- yarn.lock | 5 ----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 558fcaf..3a424c5 100644 --- a/package.json +++ b/package.json @@ -56,9 +56,7 @@ "peerDependencies": { "tslib": "2" }, - "dependencies": { - "hyperdyperid": "^1.2.0" - }, + "dependencies": {}, "devDependencies": { "@types/benchmark": "^2.1.2", "@types/jest": "^29.5.12", diff --git a/src/buffers/utf8/CachedUtf8Decoder.ts b/src/buffers/utf8/CachedUtf8Decoder.ts index 01dd36f..fee4849 100644 --- a/src/buffers/utf8/CachedUtf8Decoder.ts +++ b/src/buffers/utf8/CachedUtf8Decoder.ts @@ -1,5 +1,12 @@ import decodeUtf8 from './decodeUtf8/v10'; -import {randomU32} from 'hyperdyperid/lib/randomU32'; + +let x = 1 + Math.round(Math.random() * ((-1>>>0)-1)); + +/** Generate a random 32-bit unsigned integer in the specified [min, max] range. */ +function randomU32(min: number, max: number): number { + x ^= x << 13; x ^= x >>> 17; x ^= x << 5; + return (x >>> 0) % (max - min + 1) + min; +} class CacheItem { constructor( diff --git a/yarn.lock b/yarn.lock index a6fbb98..98cc922 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1338,11 +1338,6 @@ human-signals@^2.1.0: resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== -hyperdyperid@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/hyperdyperid/-/hyperdyperid-1.2.0.tgz#59668d323ada92228d2a869d3e474d5a33b69e6b" - integrity sha512-Y93lCzHYgGWdrJ66yIktxiaGULYc6oGiABxhcO5AufBeOyoIdZF7bIfLaOrbM0iGIOXQQgxxRrFEnb+Y6w1n4A== - ignore@^5.3.0: version "5.3.1" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.1.tgz#5073e554cd42c5b33b394375f538b8593e34d4ef" From c8e762b1ea9f7227b15d4d652056cfc1201b6421 Mon Sep 17 00:00:00 2001 From: Vadim Dalecky Date: Tue, 30 Apr 2024 22:39:07 +0200 Subject: [PATCH 2/2] =?UTF-8?q?style:=20=F0=9F=92=84=20run=20Prettier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/buffers/utf8/CachedUtf8Decoder.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/buffers/utf8/CachedUtf8Decoder.ts b/src/buffers/utf8/CachedUtf8Decoder.ts index fee4849..caedc8c 100644 --- a/src/buffers/utf8/CachedUtf8Decoder.ts +++ b/src/buffers/utf8/CachedUtf8Decoder.ts @@ -1,11 +1,13 @@ import decodeUtf8 from './decodeUtf8/v10'; -let x = 1 + Math.round(Math.random() * ((-1>>>0)-1)); +let x = 1 + Math.round(Math.random() * ((-1 >>> 0) - 1)); /** Generate a random 32-bit unsigned integer in the specified [min, max] range. */ function randomU32(min: number, max: number): number { - x ^= x << 13; x ^= x >>> 17; x ^= x << 5; - return (x >>> 0) % (max - min + 1) + min; + x ^= x << 13; + x ^= x >>> 17; + x ^= x << 5; + return ((x >>> 0) % (max - min + 1)) + min; } class CacheItem {