Package Exports
- cookie-storage
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cookie-storage) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
cookie-storage: A Web Storage interface for Cookie.
Installation
$ npm install cookie-storage
Usage
import { CookieStorage } from 'cookie-storage';
const cookieStorage = new CookieStorage();
cookieStorage.length === 0;
cookieStorage.getItem('key') === null;
cookieStorage.setItem('key', 'value');
cookieStorage.length === 1;
cookieStorage.key(0) === 'key';
cookieStorage.getItem('key') === 'value';
cookieStorage.removeItem('key');
cookieStorage.length === 0;
cookieStorage.setItem('k1', 'v1');
cookieStorage.setItem('k2', 'v2');
cookieStorage.length === 2;
cookieStorage.clear();
cookieStorage.length === 0;
// Cookie options
cookieStorage.setItem('key', 'value', {
path: '/',
domain: 'example.com',
expires: new Date(),
secure: true,
sameSite: 'Strict' // Can be 'Strict' or 'Lax'.
});
// Use default cookie options
const storage = new CookieStorage({
path: '/',
domain: 'example.com',
expires: new Date(),
secure: true,
sameSite: 'Strict' // Can be 'Strict' or 'Lax'.
});
storage.setItem('key', 'value'); // ;path=/;domain=example.com;...
Development
$ npm install
$ npm run watch