import { devtools } from 'zustand/middleware'; import type { StateCreator, SetState, GetState, StoreApi } from 'zustand'; /** * Wrap a zustand state function with devtools, if applicable. * * @param store zustand store function. * @param name Store name. */ // eslint-disable-next-line @typescript-eslint/ban-types export function withDev( store: StateCreator, name: string, ): StateCreator { if (typeof window !== 'undefined' && process.env.NODE_ENV === 'development') { return devtools, GetState, StoreApi>(store, { name }); } return store; }