MCPcopy Index your code
hub / github.com/alik0211/hardtack

github.com/alik0211/hardtack @v5.0.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v5.0.1 ↗ · + Follow
5 symbols 9 edges 8 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

hardtack

NPM GitHub Actions Coverage Status

An ultra-light library for working with cookies in JavaScript.

Features

  • Simple API
  • Ultra-light (373 bytes minified and gzipped). No dependencies. Size Limit controls the size.
  • Encoding of forbidden characters
  • Load only the necessary method

Table of contents

Quick start

Installation

yarn add hardtack -E
# or
npm i hardtack -E

Usage

// Load the full library
import hardtack from 'hardtack';
// Load the necessary method
import get from 'hardtack/src/get';
import set from 'hardtack/src/set';
import remove from 'hardtack/src/remove';

hardtack.set('name', 'Ali', {
  path: '/',
  domain: 'gasymov.com',
  maxAge: 31536000, // 1 year
  samesite: 'lax'
});

hardtack.get(); // { name: 'Ali' };

hardtack.get('name'); // Ali;

hardtack.remove('name', {
  path: '/',
  domain: 'gasymov.com'
});

Methods

set(name: string, value: string, options)

Create a cookie

options.path: string

For example: '/', '/mydir'

If not specified, defaults to the current path of the current document location.

options.domain: string

For example: example.com or subdomain.example.com

If not specified, this defaults to the host portion of the current document location. Contrary to earlier specifications, leading dots in domain names are ignored, but browsers may decline to set the cookie containing such dots. If a domain is specified, subdomains are always included.

options.maxAge: number

You can use options['max-age'], the result will be the same.

Max age in seconds. For example: 60*60*24*365 or 31536000 for a year

options.expires: string

Date in GMT format. See Date.toUTCString() for help formatting this value.

options.secure: boolean

Cookie to only be transmitted over secure protocol as https.

options.samesite: string

SameSite prevents the browser from sending this cookie along with cross-site requests. Possible values for the flag are lax or strict.

More about the options of cookies on MDN.

get(name: string)

Get cookie value

remove(name: string, options)

Remove cookie. When you delete a cookie, you must pass the same options.path and options.domain that you passed when you created the cookie.

Extension points exported contracts — how you extend this code

Options (Interface)
(no doc)
index.d.ts

Core symbols most depended-on inside this repo

merge
called by 5
src/utils/index.js
set
called by 1
src/set/index.js
get
called by 0
src/get/index.js
remove
called by 0
src/remove/index.js

Shape

Function 4
Interface 1

Languages

TypeScript100%

Modules by API surface

src/utils/index.js1 symbols
src/set/index.js1 symbols
src/remove/index.js1 symbols
src/get/index.js1 symbols
index.d.ts1 symbols

For agents

$ claude mcp add hardtack \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact