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

1.1.0 • Public • Published

cookie-boss

Takes cookie-manager (extends prototype) and cookie (adds parse and serialize methods as class and prototype methods), and adds a toJSON method. It is the boss!

Installation

npm install cookie-boss

Usage

const CookieBoss = require('cookie-boss');
const cookieboss = new CookieBoss();
const url = 'https://github.com'
const cookiesToStore = [
    `_octo=GH1.1.1249112545.1582225594; Path=/; Domain=github.com; Expires=Sat, 20 Feb 2021 19:06:34 GMT; Secure`,
    `logged_in=no; Path=/; Domain=github.com; Expires=Sat, 20 Feb 2021 19:06:34 GMT; HttpOnly; Secure`
];
 
cookieboss.store(url, cookiesToStore);
 
const prepared = cookieboss.prepare(url);
// '_octo=GH1.1.1249112545.1582225594; logged_in=no'
 
const parsed = CookieBoss.parse(prepared);
// { _octo: 'GH1.1.1249112545.1582225594', logged_in: 'no' }
 
const json = cookieboss.toJSON();
// {
//     "github.com": [
//         "_octo=GH1.1.1249112545.1582225594; Expires=Sat, 20 Feb 2021 19:06:34 GMT; Max-Age=31611923; Path=/; Domain=github.com; secure",
//         "logged_in=no; Expires=Sat, 20 Feb 2021 19:06:34 GMT; Max-Age=31611923; Path=/; Domain=github.com; secure; HttpOnly"
//     ]
// }

Typescript supported too!

Readme

Keywords

none

Package Sidebar

Install

npm i cookie-boss

Weekly Downloads

2

Version

1.1.0

License

MIT

Unpacked Size

8.29 kB

Total Files

6

Last publish

Collaborators

  • juliarose