{"versions":{"0.1.3":{"name":"@tinyhttp/vary","description":"vary rewrite in TypeScript and ESM","version":"0.1.3","type":"module","exports":"./dist/index.js","types":"dist/index.d.ts","engines":{"node":">=12.20"},"repository":{"type":"git","url":"git+https://github.com/tinyhttp/vary.git"},"keywords":["http","esm","es","vary","nodejs","javascript"],"author":{"name":"v1rtl","email":"hi@v1rtl.site"},"license":"MIT","bugs":{"url":"https://github.com/tinyhttp/vary/issues"},"homepage":"https://github.com/tinyhttp/vary#readme","devDependencies":{"@types/node":"^20.7.1","@typescript-eslint/eslint-plugin":"^6.7.3","@typescript-eslint/parser":"^6.7.3","c8":"^8.0.1","tsm":"^2.3.0","tsup":"^7.2.0","typescript":"^5.2.2","uvu":"^0.5.6"},"publishConfig":{"access":"public"},"scripts":{"build":"tsup src/index.ts --minify-whitespace --format esm --dts","test":"tsm node_modules/uvu/bin.js test","test:coverage":"c8 --include=src pnpm test","test:report":"c8 report --reporter=text-lcov > coverage.lcov"},"_id":"@tinyhttp/vary@0.1.3","_integrity":"sha512-SoL83sQXAGiHN1jm2VwLUWQSQeDAAl1ywOm6T0b0Cg1CZhVsjoiZadmjhxF6FHCCY7OHHVaLnTgSMxTPIDLxMg==","_resolved":"/tmp/de81d32500e1ceefd3228b00fa9797d3/tinyhttp-vary-0.1.3.tgz","_from":"file:tinyhttp-vary-0.1.3.tgz","_nodeVersion":"20.7.0","_npmVersion":"10.1.0","dist":{"integrity":"sha512-SoL83sQXAGiHN1jm2VwLUWQSQeDAAl1ywOm6T0b0Cg1CZhVsjoiZadmjhxF6FHCCY7OHHVaLnTgSMxTPIDLxMg==","shasum":"f5bea4769f380c43a158832a8daad8e8b186757c","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@tinyhttp/vary/-/vary-0.1.3.tgz","fileCount":5,"unpackedSize":6013,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDfRkOfSfhFJlGC9rAGHt7q6kLwm4h4YQDDPdMcQiZElgIgZ1fFK4yqk7RfVSfdwMkR490GXb7pi86aKYqTS20FFYE="}]},"_npmUser":{"name":"anonymous","email":"hi@v1rtl.site"},"directories":{},"maintainers":[{"name":"anonymous","email":"hi@v1rtl.site"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vary_0.1.3_1695919670074_0.40368593904954175"},"_hasShrinkwrap":false,"contributors":[]}},"dist-tags":{"latest":"0.1.3"},"name":"@tinyhttp/vary","time":{"created":"2023-09-28T17:21:39.806Z","0.1.3":"2023-09-28T16:47:50.235Z","modified":"2026-01-22T20:00:31.597Z"},"readme":"# @tinyhttp/vary\n\n[![Version][v-badge-url]][npm-url] [![Downloads][dl-badge-url]][npm-url] [![GitHub Workflow Status][gh-actions-img]][github-actions] [![Codecov][cov-badge-url]][cov-url]\n\n> [`vary`](https://github.com/jshttp/vary) rewrite in TypeScript with ESM and CommonJS targets\n\nManipulate the HTTP Vary header\n\n## Install\n\n```sh\npnpm i @tinyhttp/vary\n```\n\n## API\n\n```ts\nimport { vary, append } from '@tinyhttp/vary'\n```\n\n### `vary(res, field)`\n\nAdds the given header `field` to the `Vary` response header of `res`.\nThis can be a string of a single field, a string of a valid `Vary`\nheader, or an array of multiple fields.\n\nThis will append the header if not already listed, otherwise leaves\nit listed in the current location.\n\n```ts\nvary(res, 'Origin')\n```\n\n### `append(header, field)`\n\nAdds the given header `field` to the `Vary` response header string `header`.\nThis can be a string of a single field, a string of a valid `Vary` header,\nor an array of multiple fields.\n\nThis will append the header if not already listed, otherwise leaves\nit listed in the current location. The new header string is returned.\n\n```ts\n// Get header string appending \"Origin\" to \"Accept, User-Agent\"\nappend('Accept, User-Agent', 'Origin')\n```\n\n## Examples\n\n```ts\nimport { createServer } from 'node:http'\nimport { vary } from '@tinyhttp/vary'\n\ncreateServer((req, res) => {\n  // about to user-agent sniff\n  vary(res, 'User-Agent')\n\n  const ua = req.headers['user-agent'] || ''\n  const isMobile = /mobi|android|touch|mini/i.test(ua)\n\n  // serve site, depending on isMobile\n  res.setHeader('Content-Type', 'text/html')\n  res.end('You are (probably) ' + (isMobile ? '' : 'not ') + 'a mobile user')\n})\n```\n\n## License\n\nMIT © [v1rtl](https://v1rtl.site)\n\n[v-badge-url]: https://img.shields.io/npm/v/@tinyhttp/vary.svg?style=for-the-badge&color=FF69B4&label=&logo=npm\n[npm-url]: https://www.npmjs.com/package/@tinyhttp/vary\n[cov-badge-url]: https://img.shields.io/coveralls/github/tinyhttp/vary?style=for-the-badge&color=FF69B4\n[cov-url]: https://coveralls.io/github/tinyhttp/vary\n[dl-badge-url]: https://img.shields.io/npm/dt/@tinyhttp/vary?style=for-the-badge&color=FF69B4\n[github-actions]: https://github.com/tinyhttp/vary/actions\n[gh-actions-img]: https://img.shields.io/github/actions/workflow/status/tinyhttp/vary/main.yml?branch=master&style=for-the-badge&color=FF69B4&label=&logo=github","users":{}}