sparc - v1.0.1
    Preparing search index...

    Function enforceStrictObject

    • Creates a strict proxy wrapper around an object that throws an error when accessing non-existent properties.

      This function wraps the provided object in a Proxy that intercepts property access operations. If an attempt is made to access a property that doesn't exist on the object, a SystemError is thrown instead of returning undefined. This helps catch typos and invalid property accesses at runtime.

      Type Parameters

      • T extends object

        The type of the object to be wrapped, must extend Object.

      Parameters

      • obj: T

        The object to wrap with strict property access enforcement.

      Returns T

      A proxied version of the object that throws SystemError when accessing non-existent properties.

      When attempting to access a property that doesn't exist on the object.

      const config = enforceStrictObject({ apiKey: 'secret', timeout: 5000 });
      console.log(config.apiKey); // 'secret'
      console.log(config.invalid); // Throws SystemError