Skip to content

feat: Add lightweight Node.js document shim and enhance type checking guards#186

Open
Patrick-ring-motive wants to merge 14 commits intomarkcellus:nextfrom
Patrick-ring-motive:next
Open

feat: Add lightweight Node.js document shim and enhance type checking guards#186
Patrick-ring-motive wants to merge 14 commits intomarkcellus:nextfrom
Patrick-ring-motive:next

Conversation

@Patrick-ring-motive
Copy link

This PR makes two primary improvements to the CookieStore polyfill:
1. Node.js Compatibility:
• Introduces a lightweight shim for the document object to support environments (like Node.js) where a native document is missing.
• The shim creates a minimal document with a mutable cookie property, allowing the polyfill to operate outside of browser contexts without breaking existing behavior.
2. Enhanced Type Checking:
• Improves type checking guards across the codebase by using helper functions (e.g., isString, isNumber, isNullish, etc.).
• These changes ensure more robust input validation and better error handling without affecting the current API.

Motivation and Benefits:
• Cross-Environment Support:
Developers can now use the CookieStore polyfill seamlessly in both browser and Node.js environments.
• Code Reliability:
The enhanced type guards reduce the risk of runtime errors, making the polyfill more resilient and easier to maintain.

Testing and Backwards Compatibility:
• All changes have been tested to ensure that the polyfill works as expected in environments with a native document as well as in Node.js.
• Existing functionality remains unchanged, preserving backward compatibility.

Please let me know if there are any questions or further adjustments needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant