Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03.1k
1# cookie2 3[![NPM Version][npm-version-image]][npm-url]4[![NPM Downloads][npm-downloads-image]][npm-url]5[![Build Status][ci-image]][ci-url]6[![Coverage Status][coverage-image]][coverage-url]7 8Basic HTTP cookie parser and serializer for HTTP servers.9 10## Installation11 12```sh13$ npm install cookie14```15 16## API17 18```js19const cookie = require("cookie");20// import * as cookie from 'cookie';21```22 23### cookie.parseCookie(str, options)24 25Parse an HTTP `Cookie` header string and return an [object](#cookie-object) of all cookie name-value pairs.26The `str` argument is the string representing a `Cookie` header value and `options` is an27optional object containing additional parsing options.28 29```js30const cookieObject = cookie.parseCookie("foo=bar; equation=E%3Dmc%5E2");31// { foo: 'bar', equation: 'E=mc^2' }32```33 34#### Options35 36- `decode` Specifies the function to decode a [cookie-value](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1). Defaults to [`decodeURIComponent`](#encode-and-decode).37 38### cookie.stringifyCookie(cookieObj, options)39 40Stringifies a [cookie object](#cookie-object) into an HTTP `Cookie` header.41 42```js43const cookieHeader = cookie.stringify({ a: "foo", b: "bar" });44// a=foo; b=bar45```46 47#### Options48 49- `encode` Specifies the function to encode a [cookie-value](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1). Defaults to [`encodeURIComponent`](#encode-and-decode).50 51### cookie.parseSetCookie(str, options)52 53Parse an HTTP `Set-Cookie` header string and return an [object](#set-cookie-object) of the options.54 55```js56const setCookieObject = cookie.parseSetCookie("foo=bar; httpOnly");57// { name: "foo", value: "bar", httpOnly: true }58```59 60**Note:** Cookie follows the specification and ignores invalid attributes, but does not attempt to normalize or modify any attributes as a browser might. For example:61 62```js63cookie.parseSetCookie(64 "session=abc; max-age=1.5; expires=invalid; custom=value; domain=example.com",65);66// { name: "session", value: "abc", domain: "example.com" }67```68 69#### Options70 71- `decode` Specifies the function to decode a [cookie-value](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1). Defaults to [`decodeURIComponent`](#encode-and-decode).72 73### cookie.stringifySetCookie(setCookieObj, options)74 75Stringifies a [`Set-Cookie` object](#set-cookie-object) into a `Set-Cookie` header string.76 77```js78const setCookieHeader = cookie.stringifySetCookie({79 name: "foo",80 value: "bar",81});82// foo=bar83```84 85#### Options86 87- `encode` Specifies the function to encode a [cookie-value](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1). Defaults to [`encodeURIComponent`](#encode-and-decode).88 89## Cookie object90 91The cookie object represents all cookie name-value pairs in a `Cookie` header, where `{ name: "value" }` is used for `name=value`.92 93## `Set-Cookie` object94 95The `Set-Cookie` object represents all the options in a `Set-Cookie` header.96 97### name98 99The name of the cookie.100 101### value102 103The value of a cookie after it has been [decoded](#encode-and-decode).104 105### maxAge106 107Specifies the `number` (in seconds) to be the value for the [`Max-Age` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.2).108 109The [cookie storage model specification](https://tools.ietf.org/html/rfc6265#section-5.3) states that if both `expires` and110`maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,111so if both are set, they should point to the same date and time.112 113### expires114 115Specifies the `Date` object to be the value for the [`Expires` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.1).116When no expiration is set, clients consider this a "non-persistent cookie" and delete it when the current session is over.117 118The [cookie storage model specification](https://tools.ietf.org/html/rfc6265#section-5.3) states that if both `expires` and119`maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,120so if both are set, they should point to the same date and time.121 122### domain123 124Specifies the value for the [`Domain` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.3).125When no domain is set, clients consider the cookie to apply to the current domain only.126 127### path128 129Specifies the value for the [`Path` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.4).130When no path is set, the path is considered the ["default path"](https://tools.ietf.org/html/rfc6265#section-5.1.4).131 132### httpOnly133 134Enables the [`HttpOnly` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.6).135When enabled, clients will not allow client-side JavaScript to see the cookie in `document.cookie`.136 137### secure138 139Enables the [`Secure` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.5).140When enabled, clients will only send the cookie back if the browser has an HTTPS connection.141 142### partitioned143 144Enables the [`Partitioned` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-cutler-httpbis-partitioned-cookies/).145When enabled, clients will only send the cookie back when the current domain _and_ top-level domain matches.146 147This is an attribute that has not yet been fully standardized, and may change in the future.148This also means clients may ignore this attribute until they understand it. More information149about can be found in [the proposal](https://github.com/privacycg/CHIPS).150 151### priority152 153Specifies the value for the [`Priority` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1).154 155- `'low'` will set the `Priority` attribute to `Low`.156- `'medium'` will set the `Priority` attribute to `Medium`, the default priority when not set.157- `'high'` will set the `Priority` attribute to `High`.158 159More information about priority levels can be found in [the specification](https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1).160 161### sameSite162 163Specifies the value for the [`SameSite` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7).164 165- `true` will set the `SameSite` attribute to `Strict` for strict same site enforcement.166- `'lax'` will set the `SameSite` attribute to `Lax` for lax same site enforcement.167- `'none'` will set the `SameSite` attribute to `None` for an explicit cross-site cookie.168- `'strict'` will set the `SameSite` attribute to `Strict` for strict same site enforcement.169 170More information about enforcement levels can be found in [the specification](https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7).171 172## Encode and decode173 174Cookie accepts `encode` or `decode` options for processing a [cookie-value](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1).175Since the value of a cookie has a limited character set (and must be a simple string), these functions are used to transform values into strings suitable for a cookies value.176 177The default `encode` function is the global `encodeURIComponent`.178 179The default `decode` function is the global `decodeURIComponent`, wrapped in a `try..catch`. If an error180is thrown it will return the cookie's original value. If you provide your own encode/decode181scheme you must ensure errors are appropriately handled.182 183## Example184 185The following example uses this module in conjunction with the Node.js core HTTP server186to prompt a user for their name and display it back on future visits.187 188```js189var cookie = require("cookie");190var escapeHtml = require("escape-html");191var http = require("http");192var url = require("url");193 194function onRequest(req, res) {195 // Parse the query string196 var query = url.parse(req.url, true, true).query;197 198 if (query && query.name) {199 // Set a new cookie with the name200 res.setHeader(201 "Set-Cookie",202 cookie.stringifySetCookie({203 name: "name",204 value: String(query.name),205 httpOnly: true,206 maxAge: 60 * 60 * 24 * 7, // 1 week207 }),208 );209 210 // Redirect back after setting cookie211 res.statusCode = 302;212 res.setHeader("Location", req.headers.referer || "/");213 res.end();214 return;215 }216 217 // Parse the cookies on the request218 var cookies = cookie.parseCookie(req.headers.cookie || "");219 220 // Get the visitor name set in the cookie221 var name = cookies.name;222 223 res.setHeader("Content-Type", "text/html; charset=UTF-8");224 225 if (name) {226 res.write("<p>Welcome back, <b>" + escapeHtml(name) + "</b>!</p>");227 } else {228 res.write("<p>Hello, new visitor!</p>");229 }230 231 res.write('<form method="GET">');232 res.write(233 '<input placeholder="enter your name" name="name"> <input type="submit" value="Set Name">',234 );235 res.end("</form>");236}237 238http.createServer(onRequest).listen(3000);239```240 241## Testing242 243```sh244npm test245```246 247## Benchmark248 249```sh250npm run bench251```252 253```254 name hz min max mean p75 p99 p995 p999 rme samples255 · simple 8,566,313.09 0.0000 0.3694 0.0001 0.0001 0.0002 0.0002 0.0003 ±0.64% 4283157 fastest256 · decode 3,834,348.85 0.0001 0.2465 0.0003 0.0003 0.0003 0.0004 0.0006 ±0.38% 1917175257 · unquote 8,315,355.96 0.0000 0.3824 0.0001 0.0001 0.0002 0.0002 0.0003 ±0.72% 4157880258 · duplicates 1,944,765.97 0.0004 0.2959 0.0005 0.0005 0.0006 0.0006 0.0008 ±0.24% 972384259 · 10 cookies 675,345.67 0.0012 0.4328 0.0015 0.0015 0.0019 0.0020 0.0058 ±0.75% 337673260 · 100 cookies 61,040.71 0.0152 0.4092 0.0164 0.0160 0.0196 0.0228 0.2260 ±0.71% 30521 slowest261 ✓ parse top-sites (15) 22945ms262 name hz min max mean p75 p99 p995 p999 rme samples263 · parse accounts.google.com 7,164,349.17 0.0000 0.0929 0.0001 0.0002 0.0002 0.0002 0.0003 ±0.09% 3582184264 · parse apple.com 7,817,686.84 0.0000 0.6048 0.0001 0.0001 0.0002 0.0002 0.0003 ±1.05% 3908844265 · parse cloudflare.com 7,189,841.70 0.0000 0.0390 0.0001 0.0002 0.0002 0.0002 0.0003 ±0.06% 3594921266 · parse docs.google.com 7,051,765.61 0.0000 0.0296 0.0001 0.0002 0.0002 0.0002 0.0003 ±0.06% 3525883267 · parse drive.google.com 7,349,104.77 0.0000 0.0368 0.0001 0.0001 0.0002 0.0002 0.0003 ±0.05% 3674553268 · parse en.wikipedia.org 1,929,909.49 0.0004 0.3598 0.0005 0.0005 0.0007 0.0007 0.0012 ±0.16% 964955269 · parse linkedin.com 2,225,658.01 0.0003 0.0595 0.0004 0.0005 0.0005 0.0005 0.0006 ±0.06% 1112830270 · parse maps.google.com 4,423,511.68 0.0001 0.0942 0.0002 0.0003 0.0003 0.0003 0.0005 ±0.08% 2211756271 · parse microsoft.com 3,387,601.88 0.0002 0.0725 0.0003 0.0003 0.0004 0.0004 0.0005 ±0.09% 1693801272 · parse play.google.com 7,375,980.86 0.0000 0.1994 0.0001 0.0001 0.0002 0.0002 0.0003 ±0.12% 3687991273 · parse support.google.com 4,912,267.94 0.0001 2.8958 0.0002 0.0002 0.0003 0.0003 0.0005 ±1.28% 2456134274 · parse www.google.com 3,443,035.87 0.0002 0.2783 0.0003 0.0003 0.0004 0.0004 0.0007 ±0.51% 1721518275 · parse youtu.be 1,910,492.87 0.0004 0.3490 0.0005 0.0005 0.0007 0.0007 0.0011 ±0.46% 955247276 · parse youtube.com 1,895,082.62 0.0004 0.7454 0.0005 0.0005 0.0006 0.0007 0.0013 ±0.64% 947542 slowest277 · parse example.com 21,582,835.27 0.0000 0.1095 0.0000 0.0000 0.0001 0.0001 0.0001 ±0.13% 10791418278```279 280## References281 282- [RFC 6265: HTTP State Management Mechanism](https://tools.ietf.org/html/rfc6265)283- [Same-site Cookies](https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7)284 285## License286 287[MIT](LICENSE)288 289[ci-image]: https://img.shields.io/github/actions/workflow/status/jshttp/cookie/ci.yml290[ci-url]: https://github.com/jshttp/cookie/actions/workflows/ci.yml?query=branch%3Amaster291[coverage-image]: https://img.shields.io/codecov/c/github/jshttp/cookie/master292[coverage-url]: https://app.codecov.io/gh/jshttp/cookie293[npm-downloads-image]: https://img.shields.io/npm/dm/cookie294[npm-url]: https://npmjs.org/package/cookie295[npm-version-image]: https://img.shields.io/npm/v/cookie296 