Gathering detailed insights and metrics for @sec-ant/set-cookie-parser
Gathering detailed insights and metrics for @sec-ant/set-cookie-parser
npm install @sec-ant/set-cookie-parser
Typescript
Module System
Node Version
NPM Version
69.4
Supply Chain
87.3
Quality
75.5
Maintenance
100
Vulnerability
100
License
TypeScript (100%)
Total Downloads
1,118
Last Day
1
Last Week
5
Last Month
27
Last Year
427
1 Stars
67 Commits
1 Watching
2 Branches
2 Contributors
Latest Version
0.0.5
Package Id
@sec-ant/set-cookie-parser@0.0.5
Unpacked Size
10.54 kB
Size
4.02 kB
File Count
6
NPM Version
9.8.1
Node Version
18.17.1
Publised On
13 Sept 2023
Cumulative downloads
Total Downloads
Last day
-92.3%
1
Compared to previous day
Last week
-64.3%
5
Compared to previous week
Last month
285.7%
27
Compared to previous month
Last year
-38.2%
427
Compared to previous year
Yet another Set-Cookie
parser.
1npm i @sec-ant/set-cookie-parser
This package provides three main functions: parse
, parseString
, and splitCookiesString
.
parse
The parse
function takes a string or an array of strings representing cookies and an options object of type ParseOptions
. It returns an array of objects representing the parsed cookies if the map
property of the options object is false
or not provided. If the map
property is true
, it returns an object with the cookie names as keys and the parsed cookies as values.
1import { parse, ParseOptions } from "@sec-ant/set-cookie-parser"; 2 3const cookies = "name=value; expires=Wed, 21 Oct 2021 07:28:00 GMT; secure"; 4const options: ParseOptions = { 5 decodeValues: true, 6 map: true, 7}; 8const parsedCookies = parse(cookies, options); 9console.log(parsedCookies);
parseString
The parseString
function takes a string representing a single cookie and an optional configuration object of type ParseStringOptions
. It returns an object representing the parsed cookie.
1import { parseString, ParseStringOptions } from "@sec-ant/set-cookie-parser"; 2 3const cookie = "name=value; expires=Wed, 21 Oct 2021 07:28:00 GMT; secure"; 4const options: ParseStringOptions = { 5 decodeValues: true, 6}; 7const parsedCookie = parseString(cookie, options); 8console.log(parsedCookie);
splitCookiesString
The splitCookiesString
function takes a string representing multiple cookies separated by commas. It returns an array of strings representing the individual cookies.
1import { splitCookiesString } from "@sec-ant/set-cookie-parser"; 2 3const cookies = 4 "name1=value1; expires=Wed, 21 Oct 2021 07:28:00 GMT; secure, name2=value2; expires=Wed, 21 Oct 2021 07:28:00 GMT; secure"; 5const splitCookies = splitCookiesString(cookies); 6console.log(splitCookies);
The parse
and parseString
functions accept an optional configuration object as the second parameter. The configuration object can have the following properties:
decodeValues
: A boolean indicating whether to decode the cookie values using decodeURIComponent
. Defaults to true
.map
: A boolean indicating whether to return an object with the cookie names as keys and the parsed cookies as values. Only applicable to the parse
function. Defaults to false
.MIT
No vulnerabilities found.
No security vulnerabilities found.