Skip to content

Instantly share code, notes, and snippets.

@TheOnlyBeardedBeast
TheOnlyBeardedBeast / cyrb53.js
Created April 20, 2022 12:39 — forked from feeedback/cyrb53.js
fastest and simple string hash function (10^9 hashes => zero collision)
// fastest and simple string hash function (10^9 hashes => zero collision)
// keys 20 length => 1050 hash/ms
// keys 50 length => 750 hash/ms
// keys 500 length => 80 hash/ms
const cyrb53 = (key, seed = 0) => {
const A = 2654435761;
const B = 1597334677;
const C = 2246822507;
@TheOnlyBeardedBeast
TheOnlyBeardedBeast / graphqlLoader.ts
Created May 22, 2021 13:35
A graphql loader for ViteJS, enables direct gql imports into your ts code.
const gqlFileRegex = /\.(graphql|gql)$/;
function gqlLoader(): Plugin {
return {
name: "gql-loader",
transform(src, id) {
if (gqlFileRegex.test(id)) {
return {
code: `const query = "${stripIgnoredCharacters(
src