Networking · class

Fingerprint

An FNV-1a pair, fed bytes and numbers, answering sixteen hex characters.

Explained in Networking and rollback.

class Fingerprint
import { Fingerprint } from '@driftengine/network';

In depth

A class rather than a function over one buffer, because state worth fingerprinting is rarely one buffer: a consumer combines a world, a generator's position and whatever they keep beside both, and the order they feed it in is theirs to fix.

Methods

reset

reset(): this

Start again, so one instance serves a whole session without allocating.

byte

byte(value: number): this
ParameterTypeDescription
valuenumber

int32

int32(value: number): this

A 32-bit integer, low byte first.

ParameterTypeDescription
valuenumber

float

float(value: number): this

A double, as its eight bytes. See the header for why not as text.

ParameterTypeDescription
valuenumber

array

array(values: ArrayLike<number> & { BYTES_PER_ELEMENT?: number; }, count?: number): this

A typed array's bytes, up to count elements, or all of them.

ParameterTypeDescription
valuesArrayLike<number> & { BYTES_PER_ELEMENT?: number; }
count?number

digest

digest(): string

Sixteen lowercase hex characters.