1.0.1 • Published 2 years ago

parse-cookie-string v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Parse cookie string

Parse a string of cookies into a javascript object.

Install using npm i parse-cookie-string or yarn add parse-cookie-string.

Example

import { parseCookieString } from 'parse-cookie-string'; const cookies = parseCookieString(cookieString);

input: "userid=10; theme=default; jwt=somevalue"
output: {
  userId: 10,
  theme: default,
  jwt: somevalue
}

Typescript

Pass a generic to type the return value like this:

parseCookieString<{ jwt: string }>(cookies)