{"id":19383656,"url":"https://github.com/jill64/typed-qparam","last_synced_at":"2025-08-18T09:04:09.729Z","repository":{"id":199495955,"uuid":"697856513","full_name":"jill64/typed-qparam","owner":"jill64","description":"🔍 Type-safe query parameter manipulation","archived":false,"fork":false,"pushed_at":"2025-04-21T11:47:13.000Z","size":412,"stargazers_count":2,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-21T12:41:03.132Z","etag":null,"topics":["library","querystring","typesafe"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/typed-qparam","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jill64.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-09-28T16:00:08.000Z","updated_at":"2025-04-21T11:47:16.000Z","dependencies_parsed_at":"2023-10-16T03:49:16.938Z","dependency_job_id":"d1b67552-13e4-4d61-be0e-7e62052cd9ef","html_url":"https://github.com/jill64/typed-qparam","commit_stats":null,"previous_names":["jill64/typed-qparam"],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jill64%2Ftyped-qparam","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jill64%2Ftyped-qparam/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jill64%2Ftyped-qparam/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jill64%2Ftyped-qparam/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jill64","download_url":"https://codeload.github.com/jill64/typed-qparam/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250517917,"owners_count":21443862,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["library","querystring","typesafe"],"created_at":"2024-11-10T09:27:04.751Z","updated_at":"2025-04-23T21:31:58.998Z","avatar_url":"https://github.com/jill64.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!----- BEGIN GHOST DOCS HEADER -----\u003e\n\n# typed-qparam\n\n\u003c!----- BEGIN GHOST DOCS BADGES -----\u003e\n\n\u003ca href=\"https://npmjs.com/package/typed-qparam\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/typed-qparam\" alt=\"npm-version\" /\u003e\u003c/a\u003e \u003ca href=\"https://npmjs.com/package/typed-qparam\"\u003e\u003cimg src=\"https://img.shields.io/npm/l/typed-qparam\" alt=\"npm-license\" /\u003e\u003c/a\u003e \u003ca href=\"https://npmjs.com/package/typed-qparam\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/typed-qparam\" alt=\"npm-download-month\" /\u003e\u003c/a\u003e \u003ca href=\"https://npmjs.com/package/typed-qparam\"\u003e\u003cimg src=\"https://img.shields.io/bundlephobia/min/typed-qparam\" alt=\"npm-min-size\" /\u003e\u003c/a\u003e \u003ca href=\"https://github.com/jill64/typed-qparam/actions/workflows/ci.yml\"\u003e\u003cimg src=\"https://github.com/jill64/typed-qparam/actions/workflows/ci.yml/badge.svg\" alt=\"ci.yml\" /\u003e\u003c/a\u003e\n\n\u003c!----- END GHOST DOCS BADGES -----\u003e\n\n🔍 Type-safe query parameter manipulation\n\n\u003c!----- END GHOST DOCS HEADER -----\u003e\n\n\u003e [!NOTE]\n\u003e See [here](./docs/v1.md) for documentation on \u003c=v1 features.\n\n## Installation\n\n```sh\nnpm i typed-qparam\n```\n\n## Simple Usage\n\nPassing a query parameter key to the `qparam` function returns the accessor for that value.\n\n```js\nimport { extract } from 'typed-qparam'\n\nconst qparam = extract(new URL('https://example.com/?foo=bar'))\n\nconst foo = qparam('foo')\n\n// output: 'bar'\nconsole.log(foo.get())\n\n// .set() only returns a new URL instance.\n// The original URL instance is not changed.\n// No navigation of any kind will occur.\n\n// url: new URL('https://example.com/?foo=baz')\nconst url = foo.set('baz')\n\n// output: 'https://example.com/?foo=baz'\nconsole.log(url.href)\n```\n\n## Typed Param\n\nBy passing a conversion function as the second argument, you can obtain a value converted to any type.\nSee [ts-serde](https://github.com/jill64/ts-serde#readme) for more information on type guard.\n\n```js\nimport { extract } from 'typed-qparam'\nimport { number } from 'typed-qparam/serde'\n\nconst qparam = extract(new URL('https://example.com/?num=123'))\n\nconst num = qparam('num', {\n  stringify: (value) =\u003e value.toString(),\n  parse: (str) =\u003e parseInt(str)\n})\n\n// output 123\nconsole.log(num.get())\n\n// https://example.com/?key=456\nconst dist = num.set(456)\n```\n\n### Prepared Converter\n\nYou can also use the prepared converters in `typed-qparam/serde`.\nSee [ts-serde](https://github.com/jill64/ts-serde#readme) for more information on type guard\n\n```js\nimport { extract } from 'typed-qparam'\nimport { number, boolean, enums } from 'typed-qparam/serde'\n\nconst qparam = extract(\n  new URL('https://example.com/?num=123\u0026bool=true\u0026enumerate=b')\n)\n\nconst num = qparam('num', number)\nconst bool = qparam('bool', boolean)\nconst enumerate = qparam(\n  'enumerate',\n  enums(\n    ['a', 'b', 'c'],\n    'a' // fallback default value\n  )\n)\n```\n\n## Array Param\n\nSometimes you need to handle query parameters with multiple values in the same key, such as `?str=hello\u0026str=world`.  \nWith `typed-qparam`, you can treat this as an array.\n\n```js\nimport { extract, array } from 'svelte-qparam'\nimport { string, number } from 'svelte-qparam/serde'\n\nconst qparam = extract(new URL('https://example.com/?str=hello\u0026str=world'))\n\nconst str = qparam('str', array())\n// is equivalent to\n// const str = qparam('str', array(string))\n\n// if require other typed value\nconst num = qparam('num', array(number))\n\n// output ['hello', 'world']\nconsole.log(str.get())\n\n// https://example.com/?str=foo\u0026str=bar\u0026str=baz\nstr.set(['foo', 'bar', 'baz'])\n```\n\n\u003c!----- BEGIN GHOST DOCS FOOTER -----\u003e\n\n## License\n\n[MIT](LICENSE)\n\n\u003c!----- END GHOST DOCS FOOTER -----\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjill64%2Ftyped-qparam","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjill64%2Ftyped-qparam","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjill64%2Ftyped-qparam/lists"}