From 51c2b0675ad0671e9bd829107cfd5f534f39aafa Mon Sep 17 00:00:00 2001 From: Nguyen Viet Dung <29406816+magnified103@users.noreply.github.com> Date: Wed, 13 Nov 2024 17:30:00 +0700 Subject: [PATCH] Biome formatting --- packages/node/src/riblt/decoder.ts | 1 - packages/node/src/riblt/encoder.ts | 5 ++--- packages/node/src/riblt/mapping.ts | 11 ++++++++--- packages/node/tests/riblt.test.ts | 7 +++---- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/packages/node/src/riblt/decoder.ts b/packages/node/src/riblt/decoder.ts index 6fd2835b8..02000bc35 100644 --- a/packages/node/src/riblt/decoder.ts +++ b/packages/node/src/riblt/decoder.ts @@ -6,7 +6,6 @@ import type { SymbolFactory, } from "./symbol.js"; - export class Decoder extends CodingPrefix { decodedLocalSymbols: T[]; decodedRemoteSymbols: T[]; diff --git a/packages/node/src/riblt/encoder.ts b/packages/node/src/riblt/encoder.ts index c2786e6d2..8f0c74c61 100644 --- a/packages/node/src/riblt/encoder.ts +++ b/packages/node/src/riblt/encoder.ts @@ -3,10 +3,9 @@ import { type SourceSymbol, HashedSymbol, type SymbolFactory, - type CodedSymbol + type CodedSymbol, } from "./symbol.js"; - class SymbolMapping { sourceIdx: number; codedIdx: number; @@ -101,7 +100,7 @@ export class CodingPrefix { this.symbolFactory.cloneSource(symbol), ); const mapping = new RandomMapping(hashedSymbol.checksum, 0); - + this.sourceSymbols.push(hashedSymbol); this.sourceSymbolDirections.push(direction); this.mapGenerators.push(mapping); diff --git a/packages/node/src/riblt/mapping.ts b/packages/node/src/riblt/mapping.ts index 4692b6b73..0504eff3d 100644 --- a/packages/node/src/riblt/mapping.ts +++ b/packages/node/src/riblt/mapping.ts @@ -1,7 +1,7 @@ import * as crypto from "node:crypto"; function rotl(x: bigint, k: bigint) { - return BigInt.asUintN(64, ((x << k) | (x >> (64n - k)))); + return BigInt.asUintN(64, (x << k) | (x >> (64n - k))); } export class RandomMapping { @@ -9,13 +9,18 @@ export class RandomMapping { lastIdx: number; constructor(seed: Uint8Array, lastIdx = 0) { - this.s = new BigUint64Array(crypto.createHash("sha256").update(seed).digest().buffer); + this.s = new BigUint64Array( + crypto.createHash("sha256").update(seed).digest().buffer, + ); this.lastIdx = lastIdx; } nextIndex(): number { // https://prng.di.unimi.it/xoshiro256starstar.c - const result = BigInt.asUintN(64, rotl(BigInt.asUintN(64, this.s[1] * 5n), 7n) * 9n); + const result = BigInt.asUintN( + 64, + rotl(BigInt.asUintN(64, this.s[1] * 5n), 7n) * 9n, + ); const t = BigInt.asUintN(64, this.s[1] << 17n); diff --git a/packages/node/tests/riblt.test.ts b/packages/node/tests/riblt.test.ts index abedbaca8..b7691f64b 100644 --- a/packages/node/tests/riblt.test.ts +++ b/packages/node/tests/riblt.test.ts @@ -4,7 +4,6 @@ import { Decoder } from "../src/riblt/decoder.js"; import { Encoder } from "../src/riblt/encoder.js"; import { type SourceSymbol, SymbolFactory } from "../src/riblt/symbol.js"; - class VertexSymbol implements SourceSymbol { data: number; @@ -98,7 +97,7 @@ describe("RIBLT test", async () => { localDecoder.addCodedSymbol( sequenceSize - 1, localEncoder.codedSymbols[sequenceSize - 1], - remoteEncoder.codedSymbols[sequenceSize - 1] + remoteEncoder.codedSymbols[sequenceSize - 1], ); // console.log(`localDecoder[${sequenceSize - 1}]: ${localDecoder.codedSymbols[sequenceSize - 1]}`); } while (!localDecoder.tryDecode()); @@ -107,7 +106,7 @@ describe("RIBLT test", async () => { // console.log(localDecoder.decodedRemoteSymbols); // console.log(localDecoder.remaining); - console.log(`${sequenceSize/d} symbols/diff`); - } + console.log(`${sequenceSize / d} symbols/diff`); + }, ); });