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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mikosoft/cookie-storage

v1.0.4

Published

Library which helps with cookie, local and session storage management in the browser environment.

Readme

cookie-storage

Library which helps with cookie, local and session storage management in the browser environment.

Installation

$ npm install --save @mikosoft/cookie-storage

Development

Before you make any changes run npm run dev to build the library by the webpack.

Access by "window" global object

The library can be utilized by accessing its functions and features through the window global object in a web browser environment.

  • window.mikosoft.browserCookie
  • window.mikosoft.browserstorage
HTML
<script src="node_modules/cookie-storage/build/cookie-storage.js">
or
<script src="node_modules/cookie-storage/build/cookie-storage.min.js">

JS
const {BrowserCookie, BrowserStorage} = window.mikosoft;
const browserCookie = new BrowserCookie(cookieOpts);
const cookies = browserCookie.getAll();

Example

A puppeteer example.

/*** NodeJS script ***/
// inject to Chromium browser via <script> tag
await page.addScriptTag({ path: 'node_modules/cookie-storage/build/cookie-storage.min.js' }); // path to cookie-storage build file

const {cookies, localStorage} = await page.evaluate(() => {
  // cookies
  const BrowserCookie = window.mikosoft.BrowserCookie;
  const cookieOpts = {
    domain: 'adsuu.com',
    path: '/',
    expires: 5, // number of hours or exact date
    secure: false,
    httpOnly: false,
    sameSite: 'strict' // 'strict' for GET and POST, 'lax' only for POST
  };
  const browserCookie = new BrowserCookie(cookieOpts);
  const cookies = browserCookie.getAll();

  // local storage
  const BrowserStorage = window.mikosoft.BrowserStorage;
  const storageOpts = { storageType: 'local'};
  const browserStorage = new BrowserStorage(storageOpts);
  const localStorage = browserStorage.getAll();

  return {cookies, localStorage}
});

console.log('cookies::', cookies); // _ga=GA1.2.686576916.1660229610; _gid=GA1.2.2130293818.1660229610; _gat=1
console.log('localStorage::', localStorage);

Access by ESM (ECMAScript Modules)

import { BrowserCookie, BrowserStorage } from '@mikosoft/cookie-storage';

// cookie
const browserCookie = new BrowserCookie(cookieOpts);

// storage
const browserStorage = new BrowserStorage(storageOpts);

BrowserCookie API

constructor(cookieOpts) :void

interface CookieOpts {
  domain?: string;
  path?: string;
  expires?: number | Date; // number of hours or exact date
  secure?: boolean;
  httpOnly?: boolean;
  sameSite?: string; // 'strict' for GET and POST, 'lax' only for POST
}

put(name:string, value:string) :void

Set the cookie. Cookie value must be a string.

putObject(name:string, valueObj:object) :void

Set the cookie. Cookie value is object.

get(name:string) :string

Get a cookie by specific name. Returned value is string.

getObject(name:string) :object

Get a cookie by specific name. Returned value is object of parsed value.

getAll() :string

Get all cookies in array format: [{key1: val1}, {key2: val2},...] . The values (val1, val2, ...) are strings.

getObjectAll(convertType:boolean = true) :string

Get all cookies in object format: {key1: val1, key2: val2, ...}. If convertType is true then convert the value types (val1, val2), for example '5' to number 5.

remove(name:string) :void

Remove cookie by specific name.

removeAll() :void

Remove all cookies.

exists(name:string) :boolean

Check if cookie exists.

BrowserStorage API

constructor(storageOpts) :void

interface StorageOpts {
  storageType: 'local'|'session'  // default is local what means localStorage
}

put(name:string, value:string) :void

Set local or session storage. The input value can be of any type and it's saved as string.

putObject(name:string, valueObj:object) :void

Set local or session storage. The input value is object and it's saved as string.

get(name:string) :string

Get a storage value (string) by specific name. Returned value is string.

getObject(name:string) :object

Get a storage value by specific name. Returned value is object.

getAll() :string

Get all storage values in array format: [{key1: val1}, {key2: val2},...] . The values (val1, val2, ...) are strings.

getObjectAll(convertType:boolean = true) :string

Get all storage values in object format: {key1: val1, key2: val2, ...}

remove(name:string) :void

Remove storage by specific name.

removeAll() :void

Remove all storage values.

exists(name:string) :boolean

Check if storage exists.

License

The software licensed under MIT.