1.2.4 • Published 2 years ago

cache-parser v1.2.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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

Table of Contents

Installing

Node

npm install 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.umd.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

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago