Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 14 commits into
base: next
Choose a base branch
from

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