localStorageStore = (key, init, serializeAndDeserialize) => {
	const serialize = serializeAndDeserialize?.serialize ?? JSON.stringify;
	const deserialize = serializeAndDeserialize?.deserialize ?? JSON.parse;

	const store = writable(browser ? (deserialize(localStorage.getItem(key)) ?? init) : init);
	const { subscribe, set } = store;

	/** @type {(v: T) => void} */
	const flush = (v) => {
		if (browser) {
			if (typeof v === 'undefined' || v === null) {
				localStorage.removeItem(key);
			} else {
				localStorage.setItem(key, serialize(v));
			}
		}
	};

	flush(get(store));

	/** @type {Writable<T>} */
	return {
		subscribe,
		set: (v) => {
			set(v);
			flush(v);
		},
		update: (cb) => {
			const updatedStore = cb(get(store));
			set(updatedStore);
			flush(updatedStore);
		}
	};
}
Implementation of a writable store that also saves it's values to localStorage
@template T
@param {string} key localStorage key
@param {T} init
@param {SerializeAndDeserialize<T>} [serializeAndDeserialize]
@returns {Writable<T>}