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

browniejs

v1.0.0

Published

A lite getter/setter for cookies - because document.cookie is a nightmare!

Readme

Brownie.js 🍫

A lite getter/setter for cookies - because document.cookie is a nightmare to work with!

Repository: https://github.com/ez0000001000000/BrownieJS

The Problem

document.cookie is a single long string that you have to parse with complex Regex every time you want one value. It's ugly, error-prone, and makes working with cookies a pain.

The Solution

Brownie gives you brownies to work with instead of messy cookies! Internally it manages cookies, but in your app you work with delicious brownies.

Installation

npm install browniejs

Usage

// Import brownies from browniejs package
const brownies = require('browniejs');

// Set a brownie (internally stores as cookie)
brownies.set('theme', 'dark', { days: 7 });

// Get a brownie (internally reads from cookie)
const theme = brownies.get('theme'); // 'dark'

// Set an authentication brownie (secure cookie internally)
brownies.set('token', 'abc123', { 
  days: 1, 
  secure: true, 
  sameSite: 'Strict' 
});

// Check if a brownie exists
if (brownies.exists('token')) {
  console.log('User is authenticated');
}

// Get all brownies
const allBrownies = brownies.getAll();
console.log(allBrownies); // { theme: 'dark', token: 'abc123', ... }

// Remove a brownie
brownies.remove('token');

API Reference

brownies.get(name)

Get a brownie value by name.

  • Parameters:
    • name (string): The brownie name
  • Returns: The brownie value or null if not found

brownies.set(name, value, options)

Set a brownie with optional options.

  • Parameters:
    • name (string): The brownie name
    • value (string): The brownie value
    • options (object, optional):
      • days (number): Days until expiration
      • path (string): Brownie path (default: '/')
      • domain (string): Brownie domain
      • secure (boolean): Whether to use Secure flag
      • httpOnly (boolean): Whether to use HttpOnly flag (server-side only)
      • sameSite (string): SameSite policy ('Strict', 'Lax', 'None')

brownies.remove(name, options)

Remove a brownie by setting its expiration to the past.

  • Parameters:
    • name (string): The brownie name
    • options (object, optional):
      • path (string): Brownie path
      • domain (string): Brownie domain

brownies.getAll()

Get all brownies as an object.

  • Returns: Object with all brownies as key-value pairs

brownies.exists(name)

Check if a brownie exists.

  • Parameters:
    • name (string): The brownie name
  • Returns: true if brownie exists, false otherwise

Common Use Cases

Authentication Tokens

// Store auth brownie securely
brownies.set('auth_token', 'user_session_123', {
  days: 1,
  secure: true,
  sameSite: 'Strict'
});

// Check authentication
const token = brownies.get('auth_token');
if (token) {
  // User is logged in
}

Dark Mode Preference

// Save theme brownie
brownies.set('theme', 'dark', { days: 30 });

// Apply theme on page load
const theme = brownies.get('theme') || 'light';
document.body.classList.toggle('dark-mode', theme === 'dark');

User Preferences

// Save user preference brownies
brownies.set('language', 'en', { days: 365 });
brownies.set('timezone', 'America/New_York', { days: 365 });

// Load preferences
const prefs = brownies.getAll();
console.log(prefs.language, prefs.timezone);

How It Works

Brownie.js abstracts away the complexity of document.cookie. You work with brownies in your code, and Brownie handles the cookie management behind the scenes. No more parsing strings, no more complex regex - just sweet, simple brownie management!

Browser Compatibility

Brownie works in all modern browsers that support cookies. It includes safety checks to prevent errors when used in non-browser environments (like Node.js during server-side rendering).

Why "Brownie"?

Because while the browser stores cookies, you should work with brownies! 🍫 Brownies are much sweeter and easier to work with than messy cookies. Your app gets brownies, Brownie handles the cookies.

License

MIT