Ghasty003 / Lazy-Cookie

Tiny JavaScript library that makes working with cookies on client side less of a pain.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lazy-Cookie

Easy to use JavaScript/TypeScript library that makes working with cookies on client side less of a pain.

Installation

npm i lazycookie

Usage

It has same methods as localStorage & sessionStorage

import cookie from "lazycookie";

cookie.getItem("foo") // returns a string which is the value of the provided parameter.

cookie.setItem("foo", "bar", options) // sets item with key of "foo" and value of "bar".

cookie.deleteItem("foo") // deletes item with key of "foo".

cookie.clear()  // clears all key/value pairs.

cookie.length // returns the total number of key/value pair.

Optional parameters

Name Value Description
expires Date When cookie should expire in Date format.
maxAge number When cookie should expire in millisecond.

About

Tiny JavaScript library that makes working with cookies on client side less of a pain.

License:Apache License 2.0


Languages

Language:TypeScript 96.4%Language:Dockerfile 3.6%