{"id":16427576,"url":"https://github.com/cferdinandi/jar","last_synced_at":"2025-05-06T23:23:12.396Z","repository":{"id":48021739,"uuid":"154380576","full_name":"cferdinandi/jar","owner":"cferdinandi","description":"A tiny (\u003c 1kb) library that makes working with cookies easier.","archived":false,"fork":false,"pushed_at":"2024-05-19T14:59:07.000Z","size":142,"stargazers_count":40,"open_issues_count":3,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-24T17:49:14.133Z","etag":null,"topics":["cookies","javascript","javascript-library","vanilla-javascript","vanilla-js"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cferdinandi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/contributing.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-23T18:51:47.000Z","updated_at":"2024-10-17T05:37:52.000Z","dependencies_parsed_at":"2022-08-12T16:51:01.390Z","dependency_job_id":null,"html_url":"https://github.com/cferdinandi/jar","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cferdinandi%2Fjar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cferdinandi%2Fjar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cferdinandi%2Fjar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cferdinandi%2Fjar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cferdinandi","download_url":"https://codeload.github.com/cferdinandi/jar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252784017,"owners_count":21803592,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cookies","javascript","javascript-library","vanilla-javascript","vanilla-js"],"created_at":"2024-10-11T08:13:24.651Z","updated_at":"2025-05-06T23:23:12.378Z","avatar_url":"https://github.com/cferdinandi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jar [![Build Status](https://travis-ci.org/cferdinandi/jar.svg)](https://travis-ci.org/cferdinandi/jar)\nA tiny (\u003c 1kb) helper library that makes working with cookies a bit easier.\n\n[Installation](#installation) | [API](#api) | [Browser Compatibility](#browser-compatibility) | [License](#license)\n\n\u003chr\u003e\n\n### Want to learn how to write your own vanilla JS libraries? Check out my [Vanilla JS Pocket Guides](https://vanillajsguides.com/) or join the [Vanilla JS Academy](https://vanillajsacademy.com) and level-up as a web developer. 🚀\n\n\u003chr\u003e\n\n\n## Installation\n\n[The CDN is the fastest and simplest way to get started](https://cdn.jsdelivr.net/npm/jarvanillajs/dist/), but you can use importable modules or a direct download if you’d prefer.\n\n```html\n\u003c!-- Get the latest major version --\u003e\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/jarvanillajs@1/dist/jar.min.js\"\u003e\u003c/script\u003e\n```\n\nJar uses semantic versioning. You can grab a major, minor, or patch version from the CDN with the `@1.2.3` syntax. You can find all available versions [under releases](https://github.com/cferdinandi/jar/releases).\n\n**ES Modules**\n\nJar also supports modern browsers and module bundlers (like Rollup, Webpack, Snowpack, and so on) using the ES modules import syntax. Use the `.es` version.\n\n```js\nimport jar from 'https://cdn.jsdelivr.net/npm/jarvanillajs@1/dist/jar.es.min.js';\n```\n\n**NPM**\n\nYou can also use NPM (or your favorite package manager). First, install with NPM.\n\n```bash\nnpm install jarvanillajs --save\n```\n\nThen import the package.\n\n```js\nimport jar from 'jarvanillajs';\n```\n\n**CommonJS**\n\nIf you use NodeJS, you can import jar using the `require()` method with the `.cjs` version.\n\n```js\nlet jar = require('https://cdn.jsdelivr.net/npm/jarvanillajs@1/dist/jar.cjs.min.js');\n```\n\n**AMD**\n\nIf you use RequireJS, SystemJS, and other AMD formats, you can import jar with the `.amd` version.\n\n```js\nrequirejs(['https://cdn.jsdelivr.net/npm/jarvanillajs@1/dist/jar.amd.min.js'], function (jar) {\n  //...\n});\n```\n\n**Direct Download**\n\nYou can download the files directly from GitHub.\n\nCompiled and production-ready code can be found in the `dist` directory. The `src` directory contains development code.\n\n```html\n\u003cscript src=\"path/to/jar.min.js\"\u003e\u003c/script\u003e\n```\n\n\n\n## API\n\n### `set()`\n\nCreate a cookie. Pass in the cookie name and value as arguments.\n\n```js\n// Create a cookie named `sandwich` with a value of `turkey`\njar.set('sandwich', 'turkey');\n```\n\nAs an optional third argument, provide an object of options to use for the cookie. The default values are shown below.\n\n```js\nlet options = {\n\tpath: '/',         // path to set the cookie at\n\tdomain: hostname,  // domain for the cookie\n\t'max-age': null,   // maximum amount of time to keep the cookie, in seconds\n\texpires: null,     // date on which to expire the cookie (GMT format)\n\tsecure: false,     // the cookie can only be transmitted over HTTPS\n\t'same-site': 'lax' // lax|strict|none\n};\n```\n\nFor example, this cookie is set for the root path ('/'), and expires in one week (60 seconds x 60 minutes x 24 hours x 7 days)\n\n```js\njar.set('drink', 'soda', {\n\t'max-age': 60 * 60 * 24 * 7\n});\n```\n\n### `get()`\n\nGet the value of a cookie. Pass in the cookie name as an argument.\n\n```js\n// Get the `sandwich` cookie\njar.get('sandwich');\n```\n\n### `remove()`\n\nDelete a cookie.  Pass in the cookie name as an argument.\n\n```js\n// Delete the `sandwich` cookie\njar.remove('sandwich');\n```\n\nIf you passed in an option for `path` other than the default `/`, you must also provide that as a second argument.\n\n```js\n// Delete the `drink` cookie at the /order path\njar.remove('drink', '/order');\n```\n\n\n\n## Browser Compatibility\n\nJar works in all modern browsers on desktop and mobile.\n\n\n\n## License\n\nThe code is available under the [MIT License](LICENSE.md).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcferdinandi%2Fjar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcferdinandi%2Fjar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcferdinandi%2Fjar/lists"}