sugarcookie
TypeScript icon, indicating that this package has built-in type declarations

1.1.3 • Public • Published

sugarcookie

npm version test coverage npm bundle size

A sweet little HTTP cookie parser/serializer for Node.js and the browser.

npm i sugarcookie

Usage

import { parse, serialize } from 'sugarcookie'

parse('foo=bar')

// { foo: 'bar' }

serialize('foo', 'bar', {
  expires: new Date(2021, 11, 25),
  sameSite: 'Lax',
  httpOnly: true,
  secure: true,
})

// `foo=bar; Expires=Sat, 25 Dec 2021 06:00:00 GMT; SameSite=Lax; HttpOnly; Secure

Note: sugarcookie doesn't validate the values you pass in. Typescript will give you guidance, but ultimately ensuring your values match spec is up to you.

Serializer options

  • domain - string
  • expires - Date or string
  • httpOnly - boolean
  • maxAge - number in seconds
  • path - string
  • sameSite - Strict, Lax, or None
  • secure - boolean

Aliases

Of course, you can also use the aliases.

import { thaw, bake } from 'sugarcookie'

License

MIT License © Sure Thing

Readme

Keywords

none

Package Sidebar

Install

npm i sugarcookie

Weekly Downloads

1

Version

1.1.3

License

MIT

Unpacked Size

96.1 kB

Total Files

5

Last publish

Collaborators

  • estrattonbailey