asb_cloud_front/src/utils/storage.ts

6 lines
248 B
TypeScript
Raw Normal View History

export const getArrayFromLocalStorage = <T extends string = string>(name: string, sep: string | RegExp = ','): T[] | null => {
const raw = localStorage.getItem(name)
if (!raw) return null
return raw.split(sep).map<T>(elm => elm as T)
}