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 🙏

© 2024 – Pkg Stats / Ryan Hefner

koekiemonster

v2.2.1

Published

Browser and Nodejs compatible cookie interface

Downloads

19,602

Readme

koekiemonster

A node.js compatible version of cookie-monster, which is a clone of cookie-cutter. We must fork deeper yessss?

Installation

The package is released in the public npm registry as koekiemonster which is the dutch name for cookie monster and can be installed by running:

npm install --save koekiemonster

API

The module returns a single function that requires a reference to document. If you are in a Node.js environment you can pass in a object instead and it should still function as intended.

var cookie = require('koekiemonster')(document, { /* advanced options */ });
var times = parseInt(cookie.getItem('times'), 10) || 0;

cookie.setItem('times', times + 1);

The first argument is a reference to the document so it can access document.cookie the second argument is an object for advanced options. This allows you to specify a custom read and write method for cookies.

  • read Called when it needs to read all cookies and expects an array to be returned with key=cookie strings for each cookie.
  • write Called when a cookie needs to be stored, with cookie, and meta as arguments. Assumes it returns the cookie string once it's stored. The meta is an object that contains the following properties:
    • remove Boolean indicating if this is a removal request.
    • value Cookie value.
    • key Key of the cookie.
    • opts Original supplied options.

It's worth noting that if you do not supply document as first argument we will attempt to feature detect the existance of document and document.cookie automatically and default to that. In the case where it's missing, we will default to an empty object so the following will work fine in a browser based environment:

var cookie = require('koekiemonster')();

console.log(cookie.getItem('items')); // should output the same as above.

getItem(key)

Return the contents of a cookie for the given key name.

setItem(key, value, opts)

Set a new cookie with the given key as name and value as contents. You can use the opts object to configure the cookie string.

  • expires Sets the expiree of the cookie.
  • path Path of the cookie.
  • domain Domain of the cookie.
  • secure Should the cookie be secure only.

removeItem(key, opts)

Remove a cookie with the name of the key. You can use the same opts as the setItem method.

clear

Remove all cookies.

License

MIT/X11