Never underestimate a droid πŸ€–
Menu
Authors profile image

Hey there, I'm JanπŸ‘‹

...and this is my journey through time, code and space. Good luck out thereπŸ––

generated robot head
  • Nonempty record using proxy

    typescript structures

    This structure guarantees to return a string. It’s super useful for all kinds of functionality like algebraic type specification where a neutral value is required by design.

    const safeRecord = new Proxy(
      {}, {
        get: (handler: Record<PropertyKey, string>, name: PropertyKey) : string => {
          handler[name] ??= ""; return handler[name];
        }
      }
    );
    ~ 63 words