Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const cookie = require("cookie");

### cookie.parseCookie(str, options)

Alias: `parse(str, options)` ([deprecated](#deprecated))

Parse an HTTP `Cookie` header string and return an [object](#cookie-object) of all cookie name-value pairs.
The `str` argument is the string representing a `Cookie` header value and `options` is an
optional object containing additional parsing options.
Expand All @@ -40,7 +42,7 @@ const cookieObject = cookie.parseCookie("foo=bar; equation=E%3Dmc%5E2");
Stringifies a [cookie object](#cookie-object) into an HTTP `Cookie` header.

```js
const cookieHeader = cookie.stringify({ a: "foo", b: "bar" });
const cookieHeader = cookie.stringifyCookie({ a: "foo", b: "bar" });
// a=foo; b=bar
```

Expand Down Expand Up @@ -72,6 +74,8 @@ cookie.parseSetCookie(

### cookie.stringifySetCookie(setCookieObj, options)

Alias: `serialize(str, val, options)` ([deprecated](#deprecated))

Stringifies a [`Set-Cookie` object](#set-cookie-object) into a `Set-Cookie` header string.

```js
Expand Down Expand Up @@ -238,6 +242,14 @@ function onRequest(req, res) {
http.createServer(onRequest).listen(3000);
```

## Deprecated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a lightweight deprecated section and linked it, there's not a lot to include but it can be expanded in the future.


These APIs will be removed in the future:

- `parse` - use new `parseCookie` name
- `stringify` - use new `stringifySetCookie` name
- `stringify(str, val, opts)` - use `stringifySetCookie(obj, opts)`

## Testing

```sh
Expand Down
Loading