Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cache-parser

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cache-parser

A minimal Cache-Control parser.

  • 1.2.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
49K
decreased by-58.02%
Maintainers
1
Weekly downloads
 
Created
Source

Issues Stars License Codecov FOSSA Status Join the chat at https://gitter.im/tinylibs-js-org/community Speed Blazing

Latest Version Downloads JsDelivr Bundlephobia Packagephobia


  

run🏃
Cache Parser


Cache Parser is a minimal parser for the Cache-Control header.


Table of Contents


Installing

Node

npm install --save cache-parser
# or
yarn add cache-parser
const { parse, tokenize } = require('cache-parser');
import { parse, tokenize } from 'cache-parser';

Browser

<script
  crossorigin
  src="https://cdn.jsdelivr.net/npm/cache-parser@latest/dist/index.js"
></script>
const { parse, tokenize } = window.cacheParser;

Url Import

import { parse, tokenize } from 'https://cdn.skypack.dev/cache-parser@latest';

Getting Started

This package is a parser and builder for all Cache-Control directives. You can parse a string with parse() and build a http ready header with tokenize().

All needed documentation is available in form of TSDoc comments.

Usage

import { parse, CacheControl } from 'cache-parser';

const rawHeader = 'public, max-age=3600';

const {
  public, // true
  maxAge, // 3600
  immutable // undefined
} = parse(rawHeader);

const cacheProperties: CacheControl = { public: true, maxAge: 3600 };

// ['public', 'max-age=3600']
const cacheTokens = tokenize(cacheProperties);

// 'public, max-age=3600'
const httpHeader = tokens.join(', ');

License

Licensed under the MIT. See LICENSE for more informations.

FOSSA Status


FAQs

Package last updated on 28 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc