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

cooky

v2.0.0

Published

A lightweight library that allows you to manage simple cookies in JS

Downloads

1

Readme

cooky

cooky is a lightweight library that is used as a wrapper around the native JS cookie handling system.

It encapsulates all necessary methods in an handy object instead of using document.cookie in that fancily strange manner (aka document.cookie = "mynewcookie=pingas" to add a cookie and document.cookie to get the whole cookie string).

How to install ?

First, download the library either from github or npm (npm i -S cooky).

Then import/load it :

//es >= 6
import { Cooky } from "cooky"
//node
const { Cooky } = require("cooky");
<!-- as a script tag -->
<!DOCTYPE html>
<html>
  <head>
    <!-- [...] -->
    <script src="path/to/cooky.js"></script>
  </head>
  <body>
    <!-- [...] -->
  </body>
</html>

Then you'll be able to use it (either as cooky.Cooky or Cooky for in-browser use).

Functionalities

has

Cooky.has(name : String)

Determines whether or not there's a cookie associated to the given name.

Warning: Throws an error if name is not a String

getAll

Cooky.getAll()

Retrieves the cookies as an array of objects that follow the following pattern:

{
  name: String,
  value: String
}

Warning: Throws an error if there has been a problem while parsing the cookie string.

getAllAsObject

Cooky.getAllAsObject()

Retrieves the cookies, but instead of returning an array of object, it returns an objects that has the names of the cookies as keys and their respective values as values.

getAllAsMap

Cooky.getAllAsMap()

Retrieves the cookies just like getAllAsObject but send back a Map insted of a regular Object (only if available, otherwise it would throw an error).

get

Cooky.get(name : String)

Retrieves the cookie that has name as its name.

Warning: Will throw an exception if name is not a String.

set

Cooky.set(name : String, value : String)

Creates a new cookie that corresponds to name=value;

NB: You can chain set

Compatibility

Since the source code of cooky was written using ES6+ syntax and transpiled using babel and its preset env with default settings, the compatibilities are the one you obtain from transpiling using env with its default settings.

Changes

v2.0.0

In version 2.1.0, the cookie parsing algorithm has been revisited to allow parsing of object-like cookies and use of decodeURIComponent for some backend technologies.