initial commit

This commit is contained in:
2025-09-01 22:12:29 +02:00
parent b1873f9c1d
commit 02a54f61c0
5598 changed files with 903558 additions and 0 deletions

21
server/node_modules/farmhash-modern/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Forbes Lindesay
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:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

118
server/node_modules/farmhash-modern/README.md generated vendored Normal file
View File

@@ -0,0 +1,118 @@
# farmhash-modern
WASM/Web-Assembly implementation of Google's FarmHash family of very fast hash functions for use in node.js and the browser. FarmHash is the successor to CityHash. Functions in the FarmHash family are not suitable for cryptography.
The [existing farmhash npm packge](https://github.com/lovell/farmhash) works great if you can get it to build, but this can create a lot of pain. This WASM build should work on any operating system that uses node.js with zero extra configuration. It should be 100% consistent across different platforms. You can even use it in the browser. This package also includes TypeScript types, and a handy `bigqueryFingerprint` that matches BigQuery's `FARM_FINGERPRINT` function.
This WASM implementation is built using the [farmhash Rust Crate](https://crates.io/crates/farmhash). The 64-bit APIs use JavaScript's BigInt type to represent results. If you need a base-10 string, you can simply call `.toString()` on the result.
[![Build Status](https://img.shields.io/github/actions/workflow/status/ForbesLindesay/farmhash-modern/test.yml?event=push&style=for-the-badge)](https://github.com/ForbesLindesay/farmhash-modern/actions?query=workflow%3ATest+branch%3Amain)
[![Rolling Versions](https://img.shields.io/badge/Rolling%20Versions-Enabled-brightgreen?style=for-the-badge)](https://rollingversions.com/ForbesLindesay/farmhash-modern)
[![NPM version](https://img.shields.io/npm/v/farmhash-modern?style=for-the-badge)](https://www.npmjs.com/package/farmhash-modern)
[Click here for a live demo](https://farmhash.forbeslindesay.co.uk)
## Node.js
### Installation
Install using npm or yarn.
```sh
npm install farmhash-modern
# or
yarn install farmhash-modern
```
### Usage
Import using ES Module syntax or CommonJS syntax.
```typescript
import * as farmhash from 'farmhash-modern';
console.log(farmhash.fingerprint32('hello world'));
```
or
```javascript
const farmhash = require('farmhash-modern');
console.log(farmhash.fingerprint32('hello world'));
```
## Webpack
### Installation
```sh
npm install farmhash-modern
# or
yarn install farmhash-modern
```
In your `webpack.config.js` file, make sure you have set:
```js
module.exports = {
// ...
experiments: {asyncWebAssembly: true},
// ...
};
```
Also, make sure you do not have any rules that will capture `.wasm` files and turn them into URLs or some other format.
### Usage
Import using ES Module syntax syntax.
```typescript
import * as farmhash from 'farmhash-modern';
console.log(farmhash.fingerprint32('hello world'));
```
## API
### `fingerprint32(input: string | Uint8Array): number`
Create a new farmhash based u32 for a string or an array of bytes. Fingerprint value should be portable and stable across library versions and platforms.
### `fingerprint64(input: string | Uint8Array): bigint`
Create a new farmhash based u64 for a string or an array of bytes. Fingerprint value should be portable and stable across library versions and platforms.
### `bigqueryFingerprint(input: string | Uint8Array): bigint`
Create a new farmhash based i64 for a string or an array of bytes. Fingerprint value should be portable and stable across library versions and platforms.
This matches the format used by BigQuery's FARM_FINGERPRINT function.
### `hash32(input: string | Uint8Array): number`
Create a new farmhash based u32 for an array of bytes. Hash value may vary with library version.
### `hash32WithSeed(input: string | Uint8Array, seed: number): number
Create a new farmhash based u32 for an array of bytes with a given seed. Hash value may vary with library version.
### `hash64(input: string | Uint8Array): bigint`
Create a new farmhash based u64 for an array of bytes. Hash value may vary with library version.
### `hash64WithSeed(input: string | Uint8Array, seed: bigint): bigint
Create a new farmhash based u64 for an array of bytes with a given seed. Hash value may vary with library version.
## Building the web-app example
1. Install dependencies for farmhash-modern: `yarn install`
2. Build farmhash-modern: `yarn build`
3. Install dependencies for web-app: `cd web-app && npm install`
4. Build the web-app: `cd web-app && npm build`
## License
MIT

View File

@@ -0,0 +1,4 @@
import * as wasm from "./farmhash_modern_bg.wasm";
import { __wbg_set_wasm } from "./farmhash_modern_bg.js";
__wbg_set_wasm(wasm);
export * from "./farmhash_modern_bg.js";

View File

@@ -0,0 +1,235 @@
let wasm;
export function __wbg_set_wasm(val) {
wasm = val;
}
const heap = new Array(128).fill(undefined);
heap.push(undefined, null, true, false);
function getObject(idx) { return heap[idx]; }
let heap_next = heap.length;
function dropObject(idx) {
if (idx < 132) return;
heap[idx] = heap_next;
heap_next = idx;
}
function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
}
let cachedUint8Memory0 = null;
function getUint8Memory0() {
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
}
return cachedUint8Memory0;
}
let WASM_VECTOR_LEN = 0;
function passArray8ToWasm0(arg, malloc) {
const ptr = malloc(arg.length * 1, 1) >>> 0;
getUint8Memory0().set(arg, ptr / 1);
WASM_VECTOR_LEN = arg.length;
return ptr;
}
/**
* @param {Uint8Array} input
* @returns {number}
*/
export function fingerprint32(input) {
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.fingerprint32(ptr0, len0);
return ret >>> 0;
}
/**
* @param {Uint8Array} input
* @returns {bigint}
*/
export function fingerprint64(input) {
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.bigquery_fingerprint(ptr0, len0);
return BigInt.asUintN(64, ret);
}
/**
* @param {Uint8Array} input
* @returns {bigint}
*/
export function bigquery_fingerprint(input) {
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.bigquery_fingerprint(ptr0, len0);
return ret;
}
/**
* @param {Uint8Array} input
* @returns {number}
*/
export function hash32(input) {
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.hash32(ptr0, len0);
return ret >>> 0;
}
/**
* @param {Uint8Array} input
* @param {number} seed
* @returns {number}
*/
export function hash32_with_seed(input, seed) {
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.hash32_with_seed(ptr0, len0, seed);
return ret >>> 0;
}
/**
* @param {Uint8Array} input
* @returns {bigint}
*/
export function hash64(input) {
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.hash64(ptr0, len0);
return BigInt.asUintN(64, ret);
}
/**
* @param {Uint8Array} input
* @param {bigint} seed
* @returns {bigint}
*/
export function hash64_with_seed(input, seed) {
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.hash64_with_seed(ptr0, len0, seed);
return BigInt.asUintN(64, ret);
}
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
cachedTextDecoder.decode();
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}
function addHeapObject(obj) {
if (heap_next === heap.length) heap.push(heap.length + 1);
const idx = heap_next;
heap_next = heap[idx];
heap[idx] = obj;
return idx;
}
const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
let cachedTextEncoder = new lTextEncoder('utf-8');
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
? function (arg, view) {
return cachedTextEncoder.encodeInto(arg, view);
}
: function (arg, view) {
const buf = cachedTextEncoder.encode(arg);
view.set(buf);
return {
read: arg.length,
written: buf.length
};
});
function passStringToWasm0(arg, malloc, realloc) {
if (realloc === undefined) {
const buf = cachedTextEncoder.encode(arg);
const ptr = malloc(buf.length, 1) >>> 0;
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
WASM_VECTOR_LEN = buf.length;
return ptr;
}
let len = arg.length;
let ptr = malloc(len, 1) >>> 0;
const mem = getUint8Memory0();
let offset = 0;
for (; offset < len; offset++) {
const code = arg.charCodeAt(offset);
if (code > 0x7F) break;
mem[ptr + offset] = code;
}
if (offset !== len) {
if (offset !== 0) {
arg = arg.slice(offset);
}
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
const ret = encodeString(arg, view);
offset += ret.written;
}
WASM_VECTOR_LEN = offset;
return ptr;
}
let cachedInt32Memory0 = null;
function getInt32Memory0() {
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
}
return cachedInt32Memory0;
}
export function __wbg_new_abda76e883ba8a5f() {
const ret = new Error();
return addHeapObject(ret);
};
export function __wbg_stack_658279fe44541cf6(arg0, arg1) {
const ret = getObject(arg1).stack;
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len1 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len1;
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
};
export function __wbg_error_f851667af71bcfc6(arg0, arg1) {
let deferred0_0;
let deferred0_1;
try {
deferred0_0 = arg0;
deferred0_1 = arg1;
console.error(getStringFromWasm0(arg0, arg1));
} finally {
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
}
};
export function __wbindgen_object_drop_ref(arg0) {
takeObject(arg0);
};

Binary file not shown.

View File

@@ -0,0 +1,238 @@
let imports = {};
imports['__wbindgen_placeholder__'] = module.exports;
let wasm;
const { TextDecoder, TextEncoder } = require(`util`);
const heap = new Array(128).fill(undefined);
heap.push(undefined, null, true, false);
function getObject(idx) { return heap[idx]; }
let heap_next = heap.length;
function dropObject(idx) {
if (idx < 132) return;
heap[idx] = heap_next;
heap_next = idx;
}
function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
}
let cachedUint8Memory0 = null;
function getUint8Memory0() {
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
}
return cachedUint8Memory0;
}
let WASM_VECTOR_LEN = 0;
function passArray8ToWasm0(arg, malloc) {
const ptr = malloc(arg.length * 1, 1) >>> 0;
getUint8Memory0().set(arg, ptr / 1);
WASM_VECTOR_LEN = arg.length;
return ptr;
}
/**
* @param {Uint8Array} input
* @returns {number}
*/
module.exports.fingerprint32 = function(input) {
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.fingerprint32(ptr0, len0);
return ret >>> 0;
};
/**
* @param {Uint8Array} input
* @returns {bigint}
*/
module.exports.fingerprint64 = function(input) {
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.bigquery_fingerprint(ptr0, len0);
return BigInt.asUintN(64, ret);
};
/**
* @param {Uint8Array} input
* @returns {bigint}
*/
module.exports.bigquery_fingerprint = function(input) {
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.bigquery_fingerprint(ptr0, len0);
return ret;
};
/**
* @param {Uint8Array} input
* @returns {number}
*/
module.exports.hash32 = function(input) {
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.hash32(ptr0, len0);
return ret >>> 0;
};
/**
* @param {Uint8Array} input
* @param {number} seed
* @returns {number}
*/
module.exports.hash32_with_seed = function(input, seed) {
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.hash32_with_seed(ptr0, len0, seed);
return ret >>> 0;
};
/**
* @param {Uint8Array} input
* @returns {bigint}
*/
module.exports.hash64 = function(input) {
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.hash64(ptr0, len0);
return BigInt.asUintN(64, ret);
};
/**
* @param {Uint8Array} input
* @param {bigint} seed
* @returns {bigint}
*/
module.exports.hash64_with_seed = function(input, seed) {
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.hash64_with_seed(ptr0, len0, seed);
return BigInt.asUintN(64, ret);
};
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
cachedTextDecoder.decode();
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}
function addHeapObject(obj) {
if (heap_next === heap.length) heap.push(heap.length + 1);
const idx = heap_next;
heap_next = heap[idx];
heap[idx] = obj;
return idx;
}
let cachedTextEncoder = new TextEncoder('utf-8');
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
? function (arg, view) {
return cachedTextEncoder.encodeInto(arg, view);
}
: function (arg, view) {
const buf = cachedTextEncoder.encode(arg);
view.set(buf);
return {
read: arg.length,
written: buf.length
};
});
function passStringToWasm0(arg, malloc, realloc) {
if (realloc === undefined) {
const buf = cachedTextEncoder.encode(arg);
const ptr = malloc(buf.length, 1) >>> 0;
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
WASM_VECTOR_LEN = buf.length;
return ptr;
}
let len = arg.length;
let ptr = malloc(len, 1) >>> 0;
const mem = getUint8Memory0();
let offset = 0;
for (; offset < len; offset++) {
const code = arg.charCodeAt(offset);
if (code > 0x7F) break;
mem[ptr + offset] = code;
}
if (offset !== len) {
if (offset !== 0) {
arg = arg.slice(offset);
}
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
const ret = encodeString(arg, view);
offset += ret.written;
}
WASM_VECTOR_LEN = offset;
return ptr;
}
let cachedInt32Memory0 = null;
function getInt32Memory0() {
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
}
return cachedInt32Memory0;
}
module.exports.__wbg_new_abda76e883ba8a5f = function() {
const ret = new Error();
return addHeapObject(ret);
};
module.exports.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
const ret = getObject(arg1).stack;
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len1 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len1;
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
};
module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
let deferred0_0;
let deferred0_1;
try {
deferred0_0 = arg0;
deferred0_1 = arg1;
console.error(getStringFromWasm0(arg0, arg1));
} finally {
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
}
};
module.exports.__wbindgen_object_drop_ref = function(arg0) {
takeObject(arg0);
};
const path = require('path').join(__dirname, 'farmhash_modern_bg.wasm');
const bytes = require('fs').readFileSync(path);
const wasmModule = new WebAssembly.Module(bytes);
const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
wasm = wasmInstance.exports;
module.exports.__wasm = wasm;

Binary file not shown.

1
server/node_modules/farmhash-modern/lib/.tsbuildinfo generated vendored Normal file

File diff suppressed because one or more lines are too long

40
server/node_modules/farmhash-modern/lib/browser.d.ts generated vendored Normal file
View File

@@ -0,0 +1,40 @@
/**
* Create a new farmhash based u32 for a string or an array of bytes.
* Fingerprint value should be portable and stable across library versions
* and platforms.
*/
export declare function fingerprint32(input: string | Uint8Array): number;
/**
* Create a new farmhash based u64 for a string or an array of bytes.
* Fingerprint value should be portable and stable across library versions
* and platforms.
*/
export declare function fingerprint64(input: string | Uint8Array): bigint;
/**
* Create a new farmhash based i64 for a string or an array of bytes.
* Fingerprint value should be portable and stable across library versions
* and platforms.
*
* This matches the format used by BigQuery's FARM_FINGERPRINT function.
*/
export declare function bigqueryFingerprint(input: string | Uint8Array): bigint;
/**
* Create a new farmhash based u32 for an array of bytes. Hash value may
* vary with library version.
*/
export declare function hash32(input: string | Uint8Array): number;
/**
* Create a new farmhash based u32 for an array of bytes with a given seed.
* Hash value may vary with library version.
*/
export declare function hash32WithSeed(input: string | Uint8Array, seed: number): number;
/**
* Create a new farmhash based u64 for an array of bytes. Hash value may
* vary with library version.
*/
export declare function hash64(input: string | Uint8Array): bigint;
/**
* Create a new farmhash based u64 for an array of bytes with a given seed.
* Hash value may vary with library version.
*/
export declare function hash64WithSeed(input: string | Uint8Array, seed: bigint): bigint;

78
server/node_modules/farmhash-modern/lib/browser.js generated vendored Normal file
View File

@@ -0,0 +1,78 @@
import * as farmhash from '../bin/bundler/farmhash_modern.js';
function asBuffer(input) {
if (typeof input === 'string') {
return new TextEncoder().encode(input);
}
if (input instanceof Uint8Array) {
return input;
}
throw new Error('Expected input to be a string or Uint8Array');
}
function asUnsigned32BitNumber(input) {
if (input === input >>> 0) {
return input;
}
throw new Error(`Expected input to be a 32-bit unsigned integer, got ${input}`);
}
function asUnsigned64BitNumber(input) {
if (typeof input === 'bigint' &&
input >= 0 &&
input <= 18446744073709551615n) {
return input;
}
throw new Error(`Expected input to be a 64-bit unsigned integer, got ${input}`);
}
/**
* Create a new farmhash based u32 for a string or an array of bytes.
* Fingerprint value should be portable and stable across library versions
* and platforms.
*/
export function fingerprint32(input) {
return farmhash.fingerprint32(asBuffer(input));
}
/**
* Create a new farmhash based u64 for a string or an array of bytes.
* Fingerprint value should be portable and stable across library versions
* and platforms.
*/
export function fingerprint64(input) {
return farmhash.fingerprint64(asBuffer(input));
}
/**
* Create a new farmhash based i64 for a string or an array of bytes.
* Fingerprint value should be portable and stable across library versions
* and platforms.
*
* This matches the format used by BigQuery's FARM_FINGERPRINT function.
*/
export function bigqueryFingerprint(input) {
return farmhash.bigquery_fingerprint(asBuffer(input));
}
/**
* Create a new farmhash based u32 for an array of bytes. Hash value may
* vary with library version.
*/
export function hash32(input) {
return farmhash.hash32(asBuffer(input));
}
/**
* Create a new farmhash based u32 for an array of bytes with a given seed.
* Hash value may vary with library version.
*/
export function hash32WithSeed(input, seed) {
return farmhash.hash32_with_seed(asBuffer(input), asUnsigned32BitNumber(seed));
}
/**
* Create a new farmhash based u64 for an array of bytes. Hash value may
* vary with library version.
*/
export function hash64(input) {
return farmhash.hash64(asBuffer(input));
}
/**
* Create a new farmhash based u64 for an array of bytes with a given seed.
* Hash value may vary with library version.
*/
export function hash64WithSeed(input, seed) {
return farmhash.hash64_with_seed(asBuffer(input), asUnsigned64BitNumber(seed));
}

78
server/node_modules/farmhash-modern/lib/index.cjs generated vendored Normal file
View File

@@ -0,0 +1,78 @@
const farmhash = require('../bin/nodejs/farmhash_modern.js')
function asBuffer(input) {
if (typeof input === 'string') {
return new TextEncoder().encode(input);
}
if (input instanceof Uint8Array) {
return input;
}
throw new Error('Expected input to be a string or Uint8Array');
}
function asUnsigned32BitNumber(input) {
if (input === input >>> 0) {
return input;
}
throw new Error(`Expected input to be a 32-bit unsigned integer, got ${input}`);
}
function asUnsigned64BitNumber(input) {
if (typeof input === 'bigint' &&
input >= 0 &&
input <= 18446744073709551615n) {
return input;
}
throw new Error(`Expected input to be a 64-bit unsigned integer, got ${input}`);
}
/**
* Create a new farmhash based u32 for a string or an array of bytes.
* Fingerprint value should be portable and stable across library versions
* and platforms.
*/
exports.fingerprint32 = function fingerprint32(input) {
return farmhash.fingerprint32(asBuffer(input));
}
/**
* Create a new farmhash based u64 for a string or an array of bytes.
* Fingerprint value should be portable and stable across library versions
* and platforms.
*/
exports.fingerprint64 = function fingerprint64(input) {
return farmhash.fingerprint64(asBuffer(input));
}
/**
* Create a new farmhash based i64 for a string or an array of bytes.
* Fingerprint value should be portable and stable across library versions
* and platforms.
*
* This matches the format used by BigQuery's FARM_FINGERPRINT function.
*/
exports.bigqueryFingerprint = function bigqueryFingerprint(input) {
return farmhash.bigquery_fingerprint(asBuffer(input));
}
/**
* Create a new farmhash based u32 for an array of bytes. Hash value may
* vary with library version.
*/
exports.hash32 = function hash32(input) {
return farmhash.hash32(asBuffer(input));
}
/**
* Create a new farmhash based u32 for an array of bytes with a given seed.
* Hash value may vary with library version.
*/
exports.hash32WithSeed = function hash32WithSeed(input, seed) {
return farmhash.hash32_with_seed(asBuffer(input), asUnsigned32BitNumber(seed));
}
/**
* Create a new farmhash based u64 for an array of bytes. Hash value may
* vary with library version.
*/
exports.hash64 = function hash64(input) {
return farmhash.hash64(asBuffer(input));
}
/**
* Create a new farmhash based u64 for an array of bytes with a given seed.
* Hash value may vary with library version.
*/
exports.hash64WithSeed = function hash64WithSeed(input, seed) {
return farmhash.hash64_with_seed(asBuffer(input), asUnsigned64BitNumber(seed));
}

40
server/node_modules/farmhash-modern/lib/index.d.cts generated vendored Normal file
View File

@@ -0,0 +1,40 @@
/**
* Create a new farmhash based u32 for a string or an array of bytes.
* Fingerprint value should be portable and stable across library versions
* and platforms.
*/
export declare function fingerprint32(input: string | Uint8Array): number;
/**
* Create a new farmhash based u64 for a string or an array of bytes.
* Fingerprint value should be portable and stable across library versions
* and platforms.
*/
export declare function fingerprint64(input: string | Uint8Array): bigint;
/**
* Create a new farmhash based i64 for a string or an array of bytes.
* Fingerprint value should be portable and stable across library versions
* and platforms.
*
* This matches the format used by BigQuery's FARM_FINGERPRINT function.
*/
export declare function bigqueryFingerprint(input: string | Uint8Array): bigint;
/**
* Create a new farmhash based u32 for an array of bytes. Hash value may
* vary with library version.
*/
export declare function hash32(input: string | Uint8Array): number;
/**
* Create a new farmhash based u32 for an array of bytes with a given seed.
* Hash value may vary with library version.
*/
export declare function hash32WithSeed(input: string | Uint8Array, seed: number): number;
/**
* Create a new farmhash based u64 for an array of bytes. Hash value may
* vary with library version.
*/
export declare function hash64(input: string | Uint8Array): bigint;
/**
* Create a new farmhash based u64 for an array of bytes with a given seed.
* Hash value may vary with library version.
*/
export declare function hash64WithSeed(input: string | Uint8Array, seed: bigint): bigint;

40
server/node_modules/farmhash-modern/lib/index.d.mts generated vendored Normal file
View File

@@ -0,0 +1,40 @@
/**
* Create a new farmhash based u32 for a string or an array of bytes.
* Fingerprint value should be portable and stable across library versions
* and platforms.
*/
export declare function fingerprint32(input: string | Uint8Array): number;
/**
* Create a new farmhash based u64 for a string or an array of bytes.
* Fingerprint value should be portable and stable across library versions
* and platforms.
*/
export declare function fingerprint64(input: string | Uint8Array): bigint;
/**
* Create a new farmhash based i64 for a string or an array of bytes.
* Fingerprint value should be portable and stable across library versions
* and platforms.
*
* This matches the format used by BigQuery's FARM_FINGERPRINT function.
*/
export declare function bigqueryFingerprint(input: string | Uint8Array): bigint;
/**
* Create a new farmhash based u32 for an array of bytes. Hash value may
* vary with library version.
*/
export declare function hash32(input: string | Uint8Array): number;
/**
* Create a new farmhash based u32 for an array of bytes with a given seed.
* Hash value may vary with library version.
*/
export declare function hash32WithSeed(input: string | Uint8Array, seed: number): number;
/**
* Create a new farmhash based u64 for an array of bytes. Hash value may
* vary with library version.
*/
export declare function hash64(input: string | Uint8Array): bigint;
/**
* Create a new farmhash based u64 for an array of bytes with a given seed.
* Hash value may vary with library version.
*/
export declare function hash64WithSeed(input: string | Uint8Array, seed: bigint): bigint;

40
server/node_modules/farmhash-modern/lib/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,40 @@
/**
* Create a new farmhash based u32 for a string or an array of bytes.
* Fingerprint value should be portable and stable across library versions
* and platforms.
*/
export declare function fingerprint32(input: string | Uint8Array): number;
/**
* Create a new farmhash based u64 for a string or an array of bytes.
* Fingerprint value should be portable and stable across library versions
* and platforms.
*/
export declare function fingerprint64(input: string | Uint8Array): bigint;
/**
* Create a new farmhash based i64 for a string or an array of bytes.
* Fingerprint value should be portable and stable across library versions
* and platforms.
*
* This matches the format used by BigQuery's FARM_FINGERPRINT function.
*/
export declare function bigqueryFingerprint(input: string | Uint8Array): bigint;
/**
* Create a new farmhash based u32 for an array of bytes. Hash value may
* vary with library version.
*/
export declare function hash32(input: string | Uint8Array): number;
/**
* Create a new farmhash based u32 for an array of bytes with a given seed.
* Hash value may vary with library version.
*/
export declare function hash32WithSeed(input: string | Uint8Array, seed: number): number;
/**
* Create a new farmhash based u64 for an array of bytes. Hash value may
* vary with library version.
*/
export declare function hash64(input: string | Uint8Array): bigint;
/**
* Create a new farmhash based u64 for an array of bytes with a given seed.
* Hash value may vary with library version.
*/
export declare function hash64WithSeed(input: string | Uint8Array, seed: bigint): bigint;

78
server/node_modules/farmhash-modern/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,78 @@
import * as farmhash from '../bin/nodejs/farmhash_modern.js';
function asBuffer(input) {
if (typeof input === 'string') {
return new TextEncoder().encode(input);
}
if (input instanceof Uint8Array) {
return input;
}
throw new Error('Expected input to be a string or Uint8Array');
}
function asUnsigned32BitNumber(input) {
if (input === input >>> 0) {
return input;
}
throw new Error(`Expected input to be a 32-bit unsigned integer, got ${input}`);
}
function asUnsigned64BitNumber(input) {
if (typeof input === 'bigint' &&
input >= 0 &&
input <= 18446744073709551615n) {
return input;
}
throw new Error(`Expected input to be a 64-bit unsigned integer, got ${input}`);
}
/**
* Create a new farmhash based u32 for a string or an array of bytes.
* Fingerprint value should be portable and stable across library versions
* and platforms.
*/
export function fingerprint32(input) {
return farmhash.fingerprint32(asBuffer(input));
}
/**
* Create a new farmhash based u64 for a string or an array of bytes.
* Fingerprint value should be portable and stable across library versions
* and platforms.
*/
export function fingerprint64(input) {
return farmhash.fingerprint64(asBuffer(input));
}
/**
* Create a new farmhash based i64 for a string or an array of bytes.
* Fingerprint value should be portable and stable across library versions
* and platforms.
*
* This matches the format used by BigQuery's FARM_FINGERPRINT function.
*/
export function bigqueryFingerprint(input) {
return farmhash.bigquery_fingerprint(asBuffer(input));
}
/**
* Create a new farmhash based u32 for an array of bytes. Hash value may
* vary with library version.
*/
export function hash32(input) {
return farmhash.hash32(asBuffer(input));
}
/**
* Create a new farmhash based u32 for an array of bytes with a given seed.
* Hash value may vary with library version.
*/
export function hash32WithSeed(input, seed) {
return farmhash.hash32_with_seed(asBuffer(input), asUnsigned32BitNumber(seed));
}
/**
* Create a new farmhash based u64 for an array of bytes. Hash value may
* vary with library version.
*/
export function hash64(input) {
return farmhash.hash64(asBuffer(input));
}
/**
* Create a new farmhash based u64 for an array of bytes with a given seed.
* Hash value may vary with library version.
*/
export function hash64WithSeed(input, seed) {
return farmhash.hash64_with_seed(asBuffer(input), asUnsigned64BitNumber(seed));
}

78
server/node_modules/farmhash-modern/lib/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,78 @@
import * as farmhash from '../bin/nodejs/farmhash_modern.js';
function asBuffer(input) {
if (typeof input === 'string') {
return new TextEncoder().encode(input);
}
if (input instanceof Uint8Array) {
return input;
}
throw new Error('Expected input to be a string or Uint8Array');
}
function asUnsigned32BitNumber(input) {
if (input === input >>> 0) {
return input;
}
throw new Error(`Expected input to be a 32-bit unsigned integer, got ${input}`);
}
function asUnsigned64BitNumber(input) {
if (typeof input === 'bigint' &&
input >= 0 &&
input <= 18446744073709551615n) {
return input;
}
throw new Error(`Expected input to be a 64-bit unsigned integer, got ${input}`);
}
/**
* Create a new farmhash based u32 for a string or an array of bytes.
* Fingerprint value should be portable and stable across library versions
* and platforms.
*/
export function fingerprint32(input) {
return farmhash.fingerprint32(asBuffer(input));
}
/**
* Create a new farmhash based u64 for a string or an array of bytes.
* Fingerprint value should be portable and stable across library versions
* and platforms.
*/
export function fingerprint64(input) {
return farmhash.fingerprint64(asBuffer(input));
}
/**
* Create a new farmhash based i64 for a string or an array of bytes.
* Fingerprint value should be portable and stable across library versions
* and platforms.
*
* This matches the format used by BigQuery's FARM_FINGERPRINT function.
*/
export function bigqueryFingerprint(input) {
return farmhash.bigquery_fingerprint(asBuffer(input));
}
/**
* Create a new farmhash based u32 for an array of bytes. Hash value may
* vary with library version.
*/
export function hash32(input) {
return farmhash.hash32(asBuffer(input));
}
/**
* Create a new farmhash based u32 for an array of bytes with a given seed.
* Hash value may vary with library version.
*/
export function hash32WithSeed(input, seed) {
return farmhash.hash32_with_seed(asBuffer(input), asUnsigned32BitNumber(seed));
}
/**
* Create a new farmhash based u64 for an array of bytes. Hash value may
* vary with library version.
*/
export function hash64(input) {
return farmhash.hash64(asBuffer(input));
}
/**
* Create a new farmhash based u64 for an array of bytes with a given seed.
* Hash value may vary with library version.
*/
export function hash64WithSeed(input, seed) {
return farmhash.hash64_with_seed(asBuffer(input), asUnsigned64BitNumber(seed));
}

78
server/node_modules/farmhash-modern/package.json generated vendored Normal file
View File

@@ -0,0 +1,78 @@
{
"name": "farmhash-modern",
"version": "1.1.0",
"description": "FarmHash functions compiled using Rust and WebAssembly to make them easy to use in node.js and the browser",
"keywords": [
"bigquery",
"farm_fingerprint",
"farmhash",
"fingerprint",
"hash",
"rust",
"wasm",
"webassembly"
],
"main": "lib/index.cjs",
"module": "lib/index.mjs",
"types": "lib/index.d.ts",
"exports": {
"browser": "./lib/browser.js",
"import": "./lib/index.mjs",
"default": "./lib/index.cjs"
},
"files": [
"lib",
"bin"
],
"repository": "git@github.com:ForbesLindesay/npm-package-template.git",
"author": "Forbes Lindesay <forbes@lindesay.co.uk>",
"license": "MIT",
"scripts": {
"build": "yarn build:rust && yarn build:tsc",
"build:rust": "yarn build:rust:bundler && yarn build:rust:nodejs",
"build:rust:web": "wasm-pack build rust-src --target web --out-dir ../bin/web",
"build:rust:bundler": "wasm-pack build rust-src --target bundler --out-dir ../bin/bundler",
"build:rust:nodejs": "wasm-pack build rust-src --target nodejs --out-dir ../bin/nodejs",
"build:tsc": "tsc",
"postbuild": "rimraf lib/**/__tests__ && node post-build-script && rimraf web-app/node_modules/farmhash-modern && rimraf tests/node_modules/farmhash-modern && npm pack",
"lint": "eslint --config .eslintrc-ts.js --no-eslintrc --ext .ts,.tsx src",
"lint:fix": "eslint --fix --config .eslintrc-ts.js --no-eslintrc --ext .ts,.tsx src",
"prettier:write": "prettier --ignore-path .gitignore --write './**/*.{md,json,yaml,js,jsx,ts,tsx}'",
"prettier:check": "prettier --ignore-path .gitignore --list-different './**/*.{md,json,yaml,js,jsx,ts,tsx}'",
"pretest": "rimraf tests/package-lock.json && cd tests && npm install",
"test": "yarn test:cjs && yarn test:mjs && yarn test:typescript && yarn test:attw",
"test:cjs": "node tests/src/test.cjs",
"test:mjs": "node tests/src/test.mjs",
"test:typescript": "cd tests && tsc",
"test:attw": "yarn attw farmhash-modern-0.0.0.tgz"
},
"dependencies": {},
"devDependencies": {
"@arethetypeswrong/cli": "^0.4.2",
"@forbeslindesay/tsconfig": "^2.1.0",
"@types/node": "^20.3.2",
"@typescript-eslint/eslint-plugin": "^5.60.1",
"@typescript-eslint/parser": "^5.60.1",
"eslint-plugin-import": "^2.27.5",
"eslint": "^8.43.0",
"husky": "^4.2.5",
"lint-staged": "^10.1.3",
"prettier": "^2.8.8",
"rimraf": "^3.0.2",
"typescript": "^5.1.6"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{md,json,yaml,js,jsx,ts,tsx}": [
"prettier --write",
"git add"
]
},
"engines": {
"node": ">=18.0.0"
}
}