🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

cache-control-parser

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cache-control-parser - npm Package Compare versions

Comparing version
2.0.1
to
2.0.2
+1
-1
package.json
{
"name": "cache-control-parser",
"version": "2.0.1",
"version": "2.0.2",
"description": "A humble cache-control parser",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/etienne-martin/cache-control-parser",

# cache-control-parser
A humble cache-control parser.
A humble [cache-control](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control) parser.

@@ -18,3 +18,3 @@ [![Coveralls github](https://img.shields.io/coveralls/github/etienne-martin/cache-control-parser.svg)](https://coveralls.io/github/etienne-martin/cache-control-parser)

✨ **New:** you can now stringify parsed cache controls
✨ **New:** you can now stringify cache control objects

@@ -33,3 +33,3 @@ ## Getting Started

**Example** - parse a cache control string into an object:
**Example** - parse a string of cache control directives into an object:

@@ -40,3 +40,3 @@ ```javascript

const directives = parse(
"public, max-age=86400, no-transform"
"public, max-age=300, no-transform"
);

@@ -52,3 +52,3 @@

"public": true,
"max-age": 86400,
"max-age": 300,
"no-transform": true

@@ -58,5 +58,37 @@ }

**Example** - stringify a cache control object into a string:
**Example** - destructuring the cache control object:
```javascript
import { parse } from "cache-control-parser";
const directives = parse(
"max-age=300, s-maxage=0"
);
const { "max-age": maxAge, "s-maxage": sMaxAge } = directives;
```
**Example** - retrieve the shared proxy cache TTL:
```javascript
import { parse } from "cache-control-parser";
const cacheControl = parse(
"max-age=300, s-maxage=0"
);
const ttl = cacheControl["s-maxage"] ?? cacheControl["max-age"];
console.log("ttl:", ttl);
```
Output:
```json
ttl: 0
```
**Example** - stringify a cache control object:
```javascript
import { stringify } from "cache-control-parser";

@@ -63,0 +95,0 @@