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

@p0xz/cookiejar

v1.0.2

Published

Simple & lightweight cookiejar for javascript

Readme

cookiejar is simple & lightweight node.js library built for having a place where to store your cookies

Features

  • ⚡️ Fast Cookie Parsing: Efficiently parses raw cookie strings
  • 🗄️ Cookie Jar Management: Stores and manages multiple cookies
  • ⏳ Expiration Handling: Monitor and manage expiring cookies with custom warnings and removal logic
  • 🔄 Custom Cookie Interceptors: Dynamically access and update cookies with custom logic
  • 🔎 Easy Cookie Retrieval: Retrieve cookies by name
  • ✅ TypeScript Support: Built-in type definitions
  • 🚀 Zero Dependencies: Lightweight and dependency-free

Install

pnpm i @p0xz/cookiejar

Usage

import cookiejar from "@p0xz/cookiejar";

const jar = new CookieJar();

const exampleCookie = "sessionId=abc123; Domain=example.com; Path=/; Secure; HttpOnly; SameSite=Strict; Expires=Wed, 09 Jun 2025 10:18:14 GMT";

// takes an array with cookie strings and then it will proccess them
jar.setCookies([exampleCookie, ...]);

// returns 'sessionId' value
jar.getCookie("sessionId");

Expiration handling

With the expireChecker function, you can:

  • Automatically detect when cookies are about to expire and issue warnings.
  • Configure custom thresholds for warnings using the warnLimit option.
  • Remove expired cookies and trigger a callback function for custom logic.
import cookiejar from "@p0xz/cookiejar";

const jar = new CookieJar();

const exampleCookie = "sessionId=abc123; SameSite=Strict; Expires=Wed, 09 Jun 2025 10:18:14 GMT";

jar.setCookie([exampleCookie]);

jar.expireChecker("sessionId", () => {
  console.log("Session cookie has expired!");
  // handle aftermath...
}, { warnLimit: "12h", delay: 60 * 60 * 1000 }); // time is in ms

Time format for warnLimit can also be "365y 4w 30d 24h 60m 60s" (order is irrelevant)

Interceptor

With intercept, you can:

  • Dynamically update a cookie's value using a callback.
  • Check if a cookie has expired with a built-in helper method.
  • Access the raw or parsed cookie at any time.
import cookiejar from "@p0xz/cookiejar";

const jar = new CookieJar();

const exampleCookie = "sessionId=abc123; SameSite=Strict; Expires=Wed, 09 Jun 2024 10:18:14 GMT";

jar.setCookie([exampleCookie]);

const sessionIdMiddleware = jar.intercept("sessionId", (options) => {
  if (!options.isExpired()) return;

  console.warn("The sessionId cookie has expired.");
  options.update("sessionId=refreshed123; SameSite=Strict; Expires=Wed, 10 Jun 2025 10:18:14 GMT");
});

// returns cookie with interceptor behind it
sessionIdMiddleware.getCookie();

Methods

🍪 Set and Initialize Cookies

The setCookies method allows you to store and initialize multiple cookies from an array of raw cookie strings.

setCookies(_cookies: string[]);

🔍 Get All Cookies

Retrieves all stored cookies. You can choose to return either raw cookie strings or parsed cookie objects.

getCookies(raw: boolean = true);

🎯 Get a Specific Cookie

Retrieves a specific cookie by name, if it exists.

getCookie(name: string, raw: boolean = true);

🗑️ Clear All Cookies

Removes all stored cookies, leaving the cookie jar empty.

clearCookies();

🍪 Intercept cookie

The intercept method allows you to hook into a specific cookie's lifecycle, enabling dynamic modifications before it is accessed. This is useful for updating cookie values, checking expiration or adding custom behavior.

intercept(cookieName: string, callback: (options: iCookieJar.interceptorOptions) => void);

Once a cookie is intercepted, the method returns a separate getCookie function, which ensures that the interception logic does not interfere with the default getCookie method of the class.

getCookie: (raw?: boolean) => string | iCookieJar.Cookie;

📜 Interface

namespace iCookieJar {
    export interface interceptorOptions {
        update: (cookie: string) => void;
        isExpired: () => void;
    }
    export interface Cookie {
        cookieName: string;
        cookieValue: string;
        attributes: Map<string, any>;
        interceptor?: (options: interceptorOptions) => void;
        raw: string;
    }
}

License

Copyright © 2025 cookieJar

This project is protected under the GNU AGPLv3 License. For more details, refer to the LICENSE file.