import type {ReadPermalinkOptions, State} from 'read-permalink' import readPermalink, {parseBoolean, parseNumber} from 'read-permalink' const schema = { defaults: { enabled: false, }, normalizations: { count: parseNumber, enabled: parseBoolean, }, } const syncPlain = readPermalink('?count=1&enabled=false', {schema}) const count: number | undefined = syncPlain.count const enabled: boolean = syncPlain.enabled const syncState = readPermalink('?count=1', { schema, format: 'state', }) const state: State = syncState const stateCount: number | undefined = state.value.count const asyncPlain: Promise<{ count?: number enabled: boolean }> = readPermalink('?count=1', { schema, sync: false, }) const asyncState: Promise> = readPermalink('?count=1', { schema, format: 'state', sync: false, }) const reusableOptions = { schema, sync: true, } satisfies ReadPermalinkOptions const reusableResult: { count?: number enabled: boolean } = readPermalink('?count=2', reusableOptions) export {asyncPlain, asyncState, count, enabled, reusableResult, state, stateCount}