Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including cache-control-parser with all npm packages installed. Try it out:

var cacheControlParser = require("cache-control-parser")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

cache-control-parser v1.0.7

A lightweight cache-control parser

cache-control-parser

A lightweight cache-control parser.

Coveralls github CircleCI build npm version npm monthly downloads

Features

  • No dependencies
  • Built-in TypeScript support
  • Thoroughly tested

Getting Started

Installation

To use cache-control-parser in your project, run:

npm install cache-control-parser

Usage

import cacheControlParser from "cache-control-parser";

const cacheControl = cacheControlParser(
  "public, max-age=86400, no-transform"
);

console.log(cacheControl);

Output:

{
  "isPublic": true,
  "maxAge": 86400,
  "noTransform": true
}

Supported cache-control directives:

{
  maxAge?: number;
  sharedMaxAge?: number;
  staleWhileRevalidate?: number;
  staleIfError?: number;
  isPublic?: boolean;
  isPrivate?: boolean;
  noStore?: boolean;
  noCache?: boolean;
  mustRevalidate?: boolean;
  proxyRevalidate?: boolean;
  immutable?: boolean;
  noTransform?: boolean;
}

TypeScript

Type definitions are included in this library and exposed via:

import { CacheControl } from "cache-control-parser";

Built with

  • node.js - Cross-platform JavaScript run-time environment for executing JavaScript code server-side.
  • TypeScript - Typed superset of JavaScript that compiles to plain JavaScript.
  • Jest - Delightful JavaScript Testing.

Contributing

When contributing to this project, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Update the README.md with details of changes to the library.

Execute yarn test and update the tests if needed.

Testing

Run the full test suite:

yarn test

Run tests in watch mode:

yarn test:watch

Authors

License

This project is licensed under the MIT License - see the LICENSE file for details.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free