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 parseAsPageIndex parser #791

Merged
merged 14 commits into from
Feb 9, 2025
Prev Previous commit
Next Next commit
style: Formatting issues
  • Loading branch information
cenobitedk committed Feb 8, 2025
commit 30df519df586e9facee68d99f7e29a00c61ed7d1
10 changes: 5 additions & 5 deletions packages/nuqs/src/parsers.ts
Original file line number Diff line number Diff line change
@@ -157,14 +157,14 @@ export const parseAsInteger = createParser({

export const parseAsIndex = createParser({
parse: v => {
const int = parseInt(v);
const int = parseInt(v)
if (Number.isNaN(int)) {
return null;
return null
}
return int - 1;
return int - 1
},
serialize: (v) => Math.round(v + 1).toFixed(),
});
serialize: v => Math.round(v + 1).toFixed()
})

export const parseAsHex = createParser({
parse: v => {