npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

fast-cookie-read

v2.0.2

Published

A high-performance, lightweight JavaScript library for efficient cookie management in the browser. Optimized for speed and memory usage.

Readme

Fast Cookie Read

npm version License: MIT Bundle Size Tests Downloads GitHub stars

A high-performance, lightweight JavaScript library for efficient cookie management in the browser. Optimized for speed and memory usage.

Why Fast Cookie Read?

  • 🚀 High Performance: Uses efficient caching and parsing strategies
  • 📦 Lightweight: Zero dependencies, minimal bundle size
  • 🔒 Secure: Built-in validation and security features
  • 🛠 Developer Friendly: Comprehensive error handling and debugging
  • 🌐 Cross-Browser: Works in all modern browsers
  • 📝 TypeScript Support: Includes TypeScript definitions

Quick Start

npm install fast-cookie-read

Recommended Usage (Browser)

The recommended way to use Fast Cookie Read is through the global window object:

<script src="path/to/fast-cookie-read.min.js"></script>
<script>
  // Recommended: Use window.FastCookieRead
  window.FastCookieRead.setCookie('user', 'John');
  const user = window.FastCookieRead.get('user');
</script>

Module Usage (Alternative)

// Import the library
const FastCookieRead = require('fast-cookie-read');
// or
import FastCookieRead from 'fast-cookie-read';

// Set a cookie
FastCookieRead.setCookie('user', 'John');

// Get a cookie
const user = FastCookieRead.get('user'); // Returns 'John'

Features

High Performance

  • Efficient caching mechanism
  • Smart parsing strategies
  • Minimal DOM access
  • Memory-optimized operations

Security

  • Built-in validation
  • Secure cookie handling
  • XSS protection
  • CSRF protection

Developer Experience

  • TypeScript support
  • Comprehensive error handling
  • Clear documentation
  • Zero dependencies

Installation

# Using npm
npm install fast-cookie-read

# Using yarn
yarn add fast-cookie-read

# Using pnpm
pnpm add fast-cookie-read

Usage

The library is available both as a module and globally via the window object when loaded in a browser environment.

Global Usage (Recommended)

When included via script tag, the library is available globally through the window object:

<script src="path/to/fast-cookie-read.min.js"></script>
<script>
  // Recommended: Use window.FastCookieRead
  window.FastCookieRead.setCookie('user', 'John');
  const user = window.FastCookieRead.get('user');
</script>

Module Usage (Alternative)

const FastCookieRead = require('fast-cookie-read');
// or
import FastCookieRead from 'fast-cookie-read';

Basic Examples

// Set a cookie
window.FastCookieRead.setCookie('user', 'John');

// Get a cookie
const user = window.FastCookieRead.get('user'); // Returns 'John'

// Remove a cookie
window.FastCookieRead.removeCookie('user');

// Check if a cookie exists
const hasUser = window.FastCookieRead.hasCookie('user'); // Returns false

// Get all cookies
const allCookies = window.FastCookieRead.getAll(); // Returns { user: 'John', ... }

// Clear all cookies
window.FastCookieRead.clearAllCookies();

API Reference

setCookie(name, value, options)

Sets a cookie with the specified name and value.

FastCookieRead.setCookie('name', 'value', {
  expires: 7, // days from now
  maxAge: 3600, // seconds
  path: '/',
  domain: 'example.com',
  secure: true,
  sameSite: 'Strict' // 'Strict', 'Lax', or 'None'
});

get(name)

Gets the value of a cookie by name. Returns null if the cookie doesn't exist.

const value = FastCookieRead.get('name');

getAll()

Returns an object containing all cookies.

const allCookies = FastCookieRead.getAll();

removeCookie(name, options)

Removes a cookie by name.

FastCookieRead.removeCookie('name', {
  path: '/',
  domain: 'example.com'
});

hasCookie(name)

Checks if a cookie exists.

const exists = FastCookieRead.hasCookie('name');

clearAllCookies()

Removes all cookies.

FastCookieRead.clearAllCookies();

getCookieSize()

Returns the total size of all cookies in bytes.

const size = FastCookieRead.getCookieSize();

Performance

The library uses several optimizations to ensure high performance:

  1. Efficient Caching: Maintains an in-memory cache of parsed cookies
  2. Smart Parsing: Only parses cookies when necessary
  3. Minimal DOM Access: Reduces browser reflows
  4. Memory Efficient: Uses shared references where possible

Error Handling

The library includes comprehensive error handling:

  • Validates cookie names and values
  • Checks for invalid options
  • Provides clear error messages
  • Handles edge cases gracefully

Browser Support

  • Chrome (latest)
  • Firefox (latest)
  • Safari (latest)
  • Edge (latest)
  • Opera (latest)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

MIT © Nithin Murali

Support

If you find this library helpful, please consider:

  • Starring the repository
  • Opening issues for bugs or feature requests
  • Contributing to the project
  • Supporting the project through GitHub Sponsors