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

crumble

v3.0.1

Published

A RFC-6265 compliant library that makes reading and writing cookies easy.

Readme

crumble

Available from NPM Built using GitHub Action

A RFC-6265 compliant library that makes reading and writing cookies easy.

Usage

This module can be treated as an ES module:

import * as crumble from 'crumble';
// or
import { getCookie, hasCookie, setCookie, removeCookie } from 'crumble';

This module can also be treated as a CommonJS module:

const crumble = require('crumble');
// or
const { getCookie, hasCookie, setCookie, removeCookie } = require('crumble');

string getCookie(string plate, string name)

Reads the value of a cookie from a plate of cookies like document.cookie.

Example usage:

let cookie = getCookie(document.cookie, 'cookie');

Note: The value will be decoded for you, and if the cookie does not exist then null will be returned instead.

bool hasCookie(string plate, string name)

Determines whether a cookie exists in a plate of cookies like document.cookie.

Example usage:

let exists = hasCookie(document.cookie, 'cookie');

string setCookie(Object crumbs [, string value])

Creates a string that will set a cookie when assigned to a plate like document.cookie.

  • name (string, required) - The name of the cookie.
  • value (string, optional) - The value of the cookie.
  • age (number, optional) - The duration (in milliseconds) of which the cookie can live. When omitted and no expires crumb is provided, the cookie will expire at the end of the session. This takes precedence over the expires crumb.
  • expires (Date|string|number, optional) - The expiry date of the cookie. When omitted and no age crumb is provided, the cookie will expire at the end of the session.
  • path (string, optional) - The path of which the cookie will be created. Defaults to the current path.
  • domain (string, optional) - The (sub)domain of which the cookie will be created. Defaults to the current domain.
  • secure (boolean, optional) - Indicates whether the cookie should only be passed over HTTPS connections. Defaults to false.
  • sameSite (string, optional) - Indicates the context restrictions that the cookie should be subject to. This can take the value of none, lax or secure. Defaults to lax.

Example usage:

document.cookie = setCookie({
  name     : 'name',
  value    : 'value',
  domain   : 'a.domain.com',
  path     : '/an/example/path',
  age      : 3600,
  secure   : false,
  sameSite : 'strict'
});

Alternatively you can separate the value from the rest of the crumbs:

document.cookie = setCookie({
  name     : 'name',
  domain   : 'a.domain.com',
  path     : '/an/example/path',
  age      : 3600,
  secure   : false,
  sameSite : 'strict'
}, 'value');

This can be useful when the cookie value is the variable and the other crumbs are fixed.

string removeCookie(Object crumbs)

Creates a string that will remove a cookie when assigned to a plate like document.cookie.

  • name (string, required) - The name of the cookie.
  • path (string, optional) - The path of which the cookie will be removed from. Defaults to the current path.
  • domain (string, optional) - The (sub)domain of which the cookie will be removed from. Defaults to the current domain.

Example usage:

document.cookie = removeCookie({
  name   : 'name',
  domain : 'a.domain.com',
  path   : '/an/example/path'
});

Note: When a cookie was set with a specific path and/or domain, then you must provide the same values during removal.

Getting started

This module is available through the Node Package Manager (NPM):

npm install crumble

Development

Building

You can build UMD and ESM versions of this module that are both ES5 compatible and minified:

npm run build

Testing

This module also has a robust test suite:

npm test

This includes a code quality check using ESLint. Please refer to the .eslintrc files to familiar yourself with the rules.

License

This module is released under the MIT License.