/** * Converts the cookies into a simple object of * property functions only. */ export function toObject(obj: object, ctx?: any) { const result = {}; Object.keys(obj) .map(key => ({ key, prop: obj[key] })) .filter(({ prop }) => prop.isProp) .forEach(({ key, prop }) => { const value = prop(undefined, { ctx }); if (value) { result[key] = value; } }); return result as T; }