paoloricciuti / sveltekit-search-params

The easiest way to read and WRITE from query parameters in sveltekit.
https://sveltekit-search-params.netlify.app
MIT License
478 stars 13 forks source link

feat: sorting search params before navigating #56

Closed paoloricciuti closed 8 months ago

paoloricciuti commented 8 months ago

Closes #51

This adds sorting before navigating to allow for better cache-ability. This is technically a breaking change (?) but i'm a bit unsure about the consequences that it might have so i might keep it as a minor

Summary by CodeRabbit

changeset-bot[bot] commented 8 months ago

🦋 Changeset detected

Latest commit: e907ec2de02698756233f47b4b2ffd5dc105f14a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ----------------------- | ----- | | sveltekit-search-params | Minor |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

coderabbitai[bot] commented 8 months ago

Walkthrough

The recent updates introduce sorting of query parameters to enhance cache hit rates for HTTP requests. By default, parameters are alphabetically sorted, and developers can customize this behavior or opt out entirely. Changes across several files ensure consistent handling of query parameters, including their declaration, storage, and testing.

Changes

File(s) Change Summary
.gitignore Added "test-results" directory to ignore list.
README.md, .../+page.svelte, .../queryparameters/+page.svelte Updated Svelte component code for handling query parameters with sorting and default values.
src/lib/sveltekit-search-params.ts Enhanced StoreOptions interface and functions for conditional sorting of query parameters.
tests/index.test.ts Added and updated test cases to verify alphabetical ordering and custom sorting functionality.

Assessment against linked issues

Objective Addressed Explanation
Sort params in URL to improve browser cache hit rate (#51) The changes ensure that query parameters are sorted to improve the cache hit rate, addressing the issue's requirements effectively.

Poem

To sort or not, a choice to make, 🐰
With parameters in line, a cache hit rate at stake.
A rabbit hops through code with glee,
For URLs aligned, as neat as can be. 🌟

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on X ?


Tips ### Chat with CodeRabbit Bot (`@coderabbitai`) - You can reply to a review comment made by CodeRabbit. - You can tag CodeRabbit on specific lines of code or files in the PR by tagging `@coderabbitai` in a comment. - You can tag `@coderabbitai` in a PR comment and ask one-off questions about the PR and the codebase. Use quoted replies to pass the context for follow-up questions. ### CodeRabbit Commands (invoked as PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger a review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - The JSON schema for the configuration file is available [here](https://coderabbit.ai/integrations/coderabbit-overrides.v2.json). - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json`
netlify[bot] commented 8 months ago

Deploy Preview for sveltekit-search-params ready!

Name Link
Latest commit e907ec2de02698756233f47b4b2ffd5dc105f14a
Latest deploy log https://app.netlify.com/sites/sveltekit-search-params/deploys/657d6ca28a397200089d6471
Deploy Preview https://deploy-preview-56--sveltekit-search-params.netlify.app/
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.