{"id":16756804,"url":"https://github.com/charmander/negapi","last_synced_at":"2026-05-21T04:06:50.092Z","repository":{"id":57309734,"uuid":"67894311","full_name":"charmander/negapi","owner":"charmander","description":"Content type negotiation for JavaScript","archived":false,"fork":false,"pushed_at":"2020-11-04T01:24:55.000Z","size":55,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-26T16:58:34.317Z","etag":null,"topics":["content-negotiation","nodejs"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/negapi","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/charmander.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-10T21:03:02.000Z","updated_at":"2020-11-04T01:24:58.000Z","dependencies_parsed_at":"2022-09-08T05:21:29.835Z","dependency_job_id":null,"html_url":"https://github.com/charmander/negapi","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/charmander/negapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charmander%2Fnegapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charmander%2Fnegapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charmander%2Fnegapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charmander%2Fnegapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/charmander","download_url":"https://codeload.github.com/charmander/negapi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charmander%2Fnegapi/sbom","scorecard":{"id":274567,"data":{"date":"2025-08-11","repo":{"name":"github.com/charmander/negapi","commit":"0c52e1411023d5aa1ad4befe16d5d5332a36f302"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/nodejs.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/charmander/negapi/nodejs.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/charmander/negapi/nodejs.yml/master?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/nodejs.yml:21","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: ISC License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-17T14:08:16.898Z","repository_id":57309734,"created_at":"2025-08-17T14:08:16.899Z","updated_at":"2025-08-17T14:08:16.899Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33288189,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-21T02:57:32.698Z","status":"ssl_error","status_checked_at":"2026-05-21T02:57:31.990Z","response_time":62,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["content-negotiation","nodejs"],"created_at":"2024-10-13T03:42:07.802Z","updated_at":"2026-05-21T04:06:50.066Z","avatar_url":"https://github.com/charmander.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# negapi\n\nnegapi helps with content negotiation by selecting the most appropriate media type for a response based on a request’s Accept header.\n\nConstructing a media type set takes **exponential space and time** on the highest number of parameters for a type. That number is typically 0, but if something significantly larger is required, this module may not be a good choice. Matching an Accept header against the set takes O(*n* log *n* + *kn*) time, where *n* is the number of ranges in the header and *k* is the number of distinct parameter names in the type set.\n\n\n## Usage\n\n```javascript\nconst {MediaType, MediaTypeSet} = require('negapi');\n\nconst types = new MediaTypeSet([\n\tnew MediaType('text', 'plain', { format: 'flowed' }),\n\tnew MediaType('application', 'json'),\n\tnew MediaType('image', 'png'),\n]);\n\nconst image = types.select('image/*, */*;q=0.5');\nconsole.log(image.subtype);  // png\n\nconst text = types.select('text/plain');\nconsole.log(text.get('format'));  // flowed\n\nconst none = types.select('*/*;q=0');\nconsole.log(none);  // null\n```\n\n\n## API\n\n### `new MediaType(type, subtype, [parameters])`\n\nCreates a media type with the given type (string), subtype (string), and parameters (object with parameters as properties). In `text/plain; format=flowed`, the `type` is `'text'`, the `subtype` is `'plain'`, and the `parameters` are `{ format: 'flowed' }`.\n\n#### `MediaType#type`\n\nThe type, as a string.\n\n#### `MediaType#subtype`\n\nThe subtype, as a string.\n\n#### `MediaType#get(name)`\n\nGets the lowercase value of a parameter by name, or `null` if the parameter doesn’t exist. The name is case-insensitive.\n\n### `new MediaTypeSet(types)`\n\nCreates a set of media types. `types` is an array of `MediaType`s ordered by descending preference.\n\n#### `MediaTypeSet#select(accept)`\n\nSelects the most client-preferred `MediaType` of the `MediaTypeSet` according to the provided `Accept` header, or `null` if no type is acceptable.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharmander%2Fnegapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcharmander%2Fnegapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharmander%2Fnegapi/lists"}