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

client-cookies

v0.8.1

Published

A modest package to easily set, get and delete cookies in Javacript.

Downloads

14

Readme

##Client Cookies

A modest package to easily set, get and delete cookies in Javacript.

Written on EcmaScript 2015, compiled to regular ES5.

Usage

import Cookies from 'client-cookies';

Cookies.set('language', 'javascript');
// Sets the 'language' cookie, expires at end of session

Cookies.get('language'); // Returns 'javascript'

Cookies.delete('language'); // Removes 'language' cookie

Cookies.get('language'); // Returns an empty string ''

Set Options

You may pass an Object as the third parameter of the set method.

The available tweakable options are:

| Name | Type | Default | Description |------------|----------------------------|---------|-------- | expires | Number, Date, String | '' | When the property is not passed along, the set cookie will expire at the end of the session. When it is passed along, then the value's type will be evaluated. If it's a number, the cookie will expire that number of days later. If it's a Date instance, the cookie's expiry will be set for that date. Lastly, if it's a string, the code will try to parse a Date instance from it, and set the expiry for then; if it's not parsable, it will be the same as if the expires property had not be set at all, so the cookie will expire at the end of the session. | secure | Boolean | false | Setting this to true, or any "truthy" value, will only allow the cookie to be trasmitted over HTTPS. | HttpOnly | Boolean | false | Setting this to true, or any "truthy" value, will only allow the cookie to be read by the server; but only if the client adheres to standards!

Examples

Cookies.set('set expiry', 'two days later', {expires: 2});
// Will expire two days later

Cookies.set('sensitive-info', '42', {secure: true, expires: 9});
// Will only be transmitted via HTTPS, and expire after 9 days.

Cookies.set('XSS protection', 'slight', {HttpOnly: 1, secure: 1});
// Will only be transmitted via HTTPS and read by the server,
// *if* the client adheres to standards.

Testing

Simply run:

npm test