lovely. got a couple of partial implementations....

update git ignore

kaas

remove large file

syncy sync
This commit is contained in:
Chris Kruining 2025-04-03 17:27:35 +02:00 committed by Chris Kruining
parent 89f526e9d9
commit 98cd4d630c
Signed by: chris
SSH key fingerprint: SHA256:nG82MUfuVdRVyCKKWqhY+pCrbz9nbX6uzUns4RKa1Pg
24 changed files with 586 additions and 76 deletions

View file

@ -1,15 +1,46 @@
export const splitAt = (subject: string, index: number): readonly [string, string] => {
if (index < 0) {
return [subject, ''];
}
import { Accessor, createEffect, createSignal, on } from "solid-js";
if (index > subject.length) {
return [subject, ''];
}
export const splitAt = (
subject: string,
index: number,
): readonly [string, string] => {
if (index < 0) {
return [subject, ""];
}
return [subject.slice(0, index), subject.slice(index + 1)];
if (index > subject.length) {
return [subject, ""];
}
return [subject.slice(0, index), subject.slice(index + 1)];
};
export const toSlug = (subject: string) => {
return subject.toLowerCase().replaceAll(' ', '-');
};
export const toSlug = (subject: string) =>
subject.toLowerCase().replaceAll(" ", "-");
export const toHex = (subject: number) => subject.toString(16).padStart(2, "0");
const encoder = new TextEncoder();
export const hash = (
algorithm: AlgorithmIdentifier,
subject: Accessor<string | null | undefined>,
) => {
const [hash, setHash] = createSignal<string>();
createEffect(
on(subject, async (subject) => {
if (subject === null || subject === undefined || subject.length === 0) {
setHash(undefined);
return;
}
const buffer = new Uint8Array(
await crypto.subtle.digest(algorithm, encoder.encode(subject)),
);
setHash(Array.from(buffer).map(toHex).join(""));
}),
);
return hash;
};