/**
 * Converts the cookies into a simple object of
 * property functions only.
 */
export function toObject<T>(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;
}
