{"id":17291337,"url":"https://github.com/cxres/sf-utils","last_synced_at":"2025-03-26T18:46:23.054Z","repository":{"id":228235799,"uuid":"773368268","full_name":"CxRes/sf-utils","owner":"CxRes","description":"Structured Field Utilities","archived":false,"fork":false,"pushed_at":"2024-03-17T19:38:36.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-01T00:27:35.694Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CxRes.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}},"created_at":"2024-03-17T13:33:39.000Z","updated_at":"2024-03-17T13:36:55.000Z","dependencies_parsed_at":"2024-03-17T19:42:59.198Z","dependency_job_id":"56b38300-1a55-4fe9-a0a4-b2d70f6684e1","html_url":"https://github.com/CxRes/sf-utils","commit_stats":null,"previous_names":["cxres/sf-utils"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CxRes%2Fsf-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CxRes%2Fsf-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CxRes%2Fsf-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CxRes%2Fsf-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CxRes","download_url":"https://codeload.github.com/CxRes/sf-utils/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245717938,"owners_count":20661151,"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":[],"created_at":"2024-10-15T10:40:47.268Z","updated_at":"2025-03-26T18:46:23.015Z","avatar_url":"https://github.com/CxRes.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Structured Field Utilities\n\nUtilities to work with structured fields parsed by the [Structured Headers](https://www.npmjs.com/package/structured-headers) library.\n\n## Installation\n\n```sh\nnpm|pnpm|yarn add structured-field-utils\n```\n\n## Usage\n\n### Media Types\n\nSetup for the following examples:\n\n```js\nimport { parseList } from \"structured-headers\";\nimport { mediaType } from \"sf-utils\";\n```\n\n#### Sort\n\nSorts an array of media-types (in the structured fields format) based on HTTP rules specified in [RFC9110].\n\n```js\nconst parsedAccept = parseList(\"text/html;level=3;q=0.7, text/html;q=0.7, text/plain;q=0.5, text/*;q=0.1\");\nconst sortedAccept = mediaType.sort(parsedAccept);\n```\n\n#### Match\n\nCompares requested media type with an allowed media type to determine if they match based on type, subtype, and parameters.\n\nReturn a `Boolean` unless any of the parameter values mismatch, in which case it returns a `Map` containing the mismatched parameters.\n\n```js\nconst match = mediaType.match(sortedAccept, [[\"text/plain\"], [\"text/html\", new Map([['level', 2]])]]);\n```\n\n## Copyright and License\n\nCopyright © 2024, [Rahul Gupta](https://cxres.pages.dev/profile#i)\n\nThe source code in this repository is released under the [Mozilla Public License v2.0](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcxres%2Fsf-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcxres%2Fsf-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcxres%2Fsf-utils/lists"}