Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yurkimus/cookies
JavaScript-utilities to handle cookies everywhere
https://github.com/yurkimus/cookies
cookie deno javascript node utilities
Last synced: 3 months ago
JSON representation
JavaScript-utilities to handle cookies everywhere
- Host: GitHub
- URL: https://github.com/yurkimus/cookies
- Owner: yurkimus
- License: mit
- Created: 2024-07-24T19:04:47.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-08-15T01:48:59.000Z (5 months ago)
- Last Synced: 2024-09-30T19:27:20.000Z (3 months ago)
- Topics: cookie, deno, javascript, node, utilities
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Cookies
JavaScript-utilities to handle cookies everywhere.
## Table of Contents
- [Installation](#installation)
- [Exports](#exports)
- [parseCookie](#parseCookie)
- [readCookie](#readCookie)
- [serializeCookie](#serializeCookie)
- [License](#license)## Installation
### npm
```
npm install @yurkimus/cookies
```### urls
```
"@yurkimus/cookies": "npm:@yurkimus/cookies"
``````
"@yurkimus/cookies": "github:yurkimus/cookies"
``````
"@yurkimus/cookies": "https://raw.githubusercontent.com/yurkimus/cookies/main/source/index.js"
```## Exports
### parseCookie
#### Definition
```
parseCookie :: string -> *
```#### Example
```javascript
parseCookie('name=John; age=30; role=admin') // => [['name', 'John'], ['age', '30'], ['role', 'admin']]
```### readCookie
#### Definition
```
readCookie :: * -> string -> *
```#### Example
```javascript
let cookie = 'name=John; age=30; role=admin'readCookie('age', cookie) // => '30'
readCookie(['age', 'name'], cookie) // => ['30', 'John']
```### serializeCookie
#### Definition
```
serializeCookie :: string -> * -> [(string, string)] -> string
```#### Example
```javascript
let attributes = [
['path', '/'],
['expires', 'Wed, 21 Oct 2026 07:28:00 GMT'],
]serializeCookie('name', 'John', attributes) // => 'name=John; path=/; expires=Wed, 21 Oct 2026 07:28:00 GMT'
```## License
[MIT](LICENSE)