# @builds-dev/cookie

> Functions for cookies.

Latest version **1.1.0** (published 2022-06-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install @builds-dev/cookie
pnpm add @builds-dev/cookie
yarn add @builds-dev/cookie
bun add @builds-dev/cookie
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2022-06-13 |
| First published | 2022-06-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Johnny Hauser |
| Maintainers | m59, craig-l |
| Keywords | cookie, header, parse, stringify |

## Links

- npm: https://www.npmjs.com/package/@builds-dev/cookie
- Repository: https://github.com/builds-dev/cookie
- Homepage: https://github.com/builds-dev/cookie#readme
- Issues: https://github.com/builds-dev/cookie/issues
- npm.io page: https://npm.io/package/@builds-dev/cookie

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2022-06-13

## README

# cookie

```node
import * as cookie from '@builds-dev/cookie'
```

<!--js
import * as cookie from './dist/esm/index.js'
-->

### `header (cookie_strings)`

Takes an array of cookie strings and returns a string suitable to use as the value of the `Cookie` header.

```js
cookie.header([
	'foo=bar; Secure; HttpOnly',
	'baz=qux; Secure'
])
// => 'foo=bar; baz=qux'
```

### `join (cookie_pairs)`

Joins an array of cookie pairs into a string.

```js
cookie.join([
	'foo=bar',
	'Expires=Thu, 21 Oct 2021 07:28:00 GMT',
	'Secure',
	'HttpOnly'
])
// => 'foo=bar; Expires=Thu, 21 Oct 2021 07:28:00 GMT; Secure; HttpOnly'
```

### `parse (cookie)`

Takes a cookie string and parses it into an object.

```js
cookie.parse('foo=bar; Expires=Thu, 21 Oct 2021 07:28:00 GMT; Secure; HttpOnly')
/*
=> {
	name: 'foo',
	value: 'bar',
	expires: 'Thu, 21 Oct 2021 07:28:00 GMT',
	secure: true,
	httponly: true
}
*/
```

### `split (cookie_string)`

Split a cookie string into an array of cookie pairs.

```js
cookie.split('foo=bar; Expires=Thu, 21 Oct 2021 07:28:00 GMT; Secure; HttpOnly')
/*
=> [
	'foo=bar',
	'Expires=Thu, 21 Oct 2021 07:28:00 GMT',
	'Secure',
	'HttpOnly'
]
*/
```

### `stringify (object)`

Takes a parsed cookie object and returns a cookie string.

```js
cookie.stringify({
	name: 'foo',
	value: 'bar',
	expires: 'Thu, 21 Oct 2021 07:28:00 GMT',
	secure: true,
	httponly: true
})
// => 'foo=bar; expires=Thu, 21 Oct 2021 07:28:00 GMT; secure; httponly'
```

---
_Source: https://npm.io/package/@builds-dev/cookie · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
