Socket
Socket
Sign inDemoInstall

@toolz/get-cookies

Package Overview
Dependencies
3
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @toolz/get-cookies

A utility function that parses cookies into an object


Version published
Weekly downloads
6
Maintainers
1
Created
Weekly downloads
 

Readme

Source

get-cookies

get-cookies is a utility function that parses cookies into an object. Its default behavior will also attempt to convert cookie values into their "logical" data types.

Usage

After installation, import the package:

import { getCookies } from '@toolz/get-cookies';

getCookies()

The function returns an object containing any existing cookie values and attempts to convert those values into native JS data types.

const API = {
   arguments: {
      convertDataTypes: {
         optional,
         format: Boolean,
         defaultValue: true,
      },
   },
   returns: Object,
}

Examples:

// document.cookies = 'isKool=true; name=mary; pi=3.14; children=null; age=42'
const cookies = getCookies();
/*
   cookies = {
      isKool: true,
      name: 'mary',
      pi: 3.14,
      children: null,
      age: 42,
   }
 */
// document.cookies = 'isKool=true; name=mary; pi=3.14; children=null; age=42'
const cookies = getCookies(false);
/*
   cookies = {
      isKool: 'true',
      name: 'mary',
      pi: '3.14',
      children: 'null',
      age: '42',
   }
 */

Keywords

FAQs

Last updated on 24 Mar 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc