{"id":25029093,"url":"https://github.com/lsphillips/crumble","last_synced_at":"2025-04-13T16:09:55.862Z","repository":{"id":25451552,"uuid":"28881627","full_name":"lsphillips/crumble","owner":"lsphillips","description":"A RFC-6265 compliant library that makes reading and writing cookies easy.","archived":false,"fork":false,"pushed_at":"2025-04-11T17:51:55.000Z","size":1254,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-13T16:09:49.595Z","etag":null,"topics":["library"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/crumble","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/lsphillips.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-01-06T20:18:45.000Z","updated_at":"2025-04-11T17:51:59.000Z","dependencies_parsed_at":"2023-02-13T01:46:00.448Z","dependency_job_id":"e6d82ac7-11e6-46e6-9b3a-d3e2708934dc","html_url":"https://github.com/lsphillips/crumble","commit_stats":{"total_commits":174,"total_committers":3,"mean_commits":58.0,"dds":"0.32183908045977017","last_synced_commit":"28edd633f2bc21822b648530d0f56fe66e97d7bb"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsphillips%2Fcrumble","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsphillips%2Fcrumble/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsphillips%2Fcrumble/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsphillips%2Fcrumble/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lsphillips","download_url":"https://codeload.github.com/lsphillips/crumble/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248741204,"owners_count":21154255,"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":["library"],"created_at":"2025-02-05T20:58:25.337Z","updated_at":"2025-04-13T16:09:55.855Z","avatar_url":"https://github.com/lsphillips.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `crumble`\n\n[![Available from NPM](https://img.shields.io/npm/v/crumble.svg?maxAge=900)](https://www.npmjs.com/package/crumble)\n[![Built using GitHub Action](https://github.com/lsphillips/crumble/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/lsphillips/crumble/actions)\n\nA RFC-6265 compliant library that makes reading and writing cookies easy.\n\n## Usage\n\nThis module can be treated as an ES module:\n\n``` js\nimport * as crumble from 'crumble';\n// or\nimport { getCookie, hasCookie, setCookie, removeCookie } from 'crumble';\n```\n\nThis module can also be treated as a CommonJS module:\n\n``` js\nconst crumble = require('crumble');\n// or\nconst { getCookie, hasCookie, setCookie, removeCookie } = require('crumble');\n```\n\n### `string getCookie(string plate, string name)`\n\nReads the value of a cookie from a plate of cookies like `document.cookie`.\n\nExample usage:\n\n``` js\nlet cookie = getCookie(document.cookie, 'cookie');\n```\n\n**Note:** The value will be decoded for you, and if the cookie does not exist then `null` will be returned instead.\n\n### `bool hasCookie(string plate, string name)`\n\nDetermines whether a cookie exists in a plate of cookies like `document.cookie`.\n\nExample usage:\n\n``` js\nlet exists = hasCookie(document.cookie, 'cookie');\n```\n\n### `string setCookie(Object crumbs [, string value])`\n\nCreates a string that will set a cookie when assigned to a plate like `document.cookie`.\n\n* `name` (string, required) - The name of the cookie.\n* `value` (string, optional) - The value of the cookie.\n* `age` (number, optional) - The duration (in milliseconds) of which the cookie can live. When omitted and no `expires` crumb is provided, the cookie will expire at the end of the session. This takes precedence over the `expires` crumb.\n* `expires` (Date|string|number, optional) - The expiry date of the cookie. When omitted and no `age` crumb is provided, the cookie will expire at the end of the session.\n* `path` (string, optional) - The path of which the cookie will be created. Defaults to the current path.\n* `domain` (string, optional) - The (sub)domain of which the cookie will be created. Defaults to the current domain.\n* `secure` (boolean, optional) - Indicates whether the cookie should only be passed over HTTPS connections. Defaults to `false`.\n* `sameSite` (string, optional) - Indicates the context restrictions that the cookie should be subject to. This can take the value of `none`, `lax` or `secure`. Defaults to `lax`.\n\nExample usage:\n\n``` js\ndocument.cookie = setCookie({\n  name     : 'name',\n  value    : 'value',\n  domain   : 'a.domain.com',\n  path     : '/an/example/path',\n  age      : 3600,\n  secure   : false,\n  sameSite : 'strict'\n});\n```\n\nAlternatively you can separate the value from the rest of the crumbs:\n\n``` js\ndocument.cookie = setCookie({\n  name     : 'name',\n  domain   : 'a.domain.com',\n  path     : '/an/example/path',\n  age      : 3600,\n  secure   : false,\n  sameSite : 'strict'\n}, 'value');\n```\n\nThis can be useful when the cookie value is the variable and the other crumbs are fixed.\n\n### `string removeCookie(Object crumbs)`\n\nCreates a string that will remove a cookie when assigned to a plate like `document.cookie`.\n\n* `name` (string, required) - The name of the cookie.\n* `path` (string, optional) - The path of which the cookie will be removed from. Defaults to the current path.\n* `domain` (string, optional) - The (sub)domain of which the cookie will be removed from. Defaults to the current domain.\n\nExample usage:\n\n``` js\ndocument.cookie = removeCookie({\n  name   : 'name',\n  domain : 'a.domain.com',\n  path   : '/an/example/path'\n});\n```\n\n**Note:** When a cookie was set with a specific path and/or domain, then you must provide the same values during removal.\n\n## Getting started\n\nThis module is available through the Node Package Manager (NPM):\n\n``` sh\nnpm install crumble\n```\n\n## Development\n\n### Building\n\nYou can build UMD and ESM versions of this module that are both ES5 compatible and minified:\n\n``` sh\nnpm run build\n```\n\n### Testing\n\nThis module also has a robust test suite:\n\n``` sh\nnpm test\n```\n\nThis includes a code quality check using ESLint. Please refer to the `eslint.config.js` files to familiar yourself with the rules.\n\n## License\n\nThis module is released under the [MIT License](LICENSE.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flsphillips%2Fcrumble","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flsphillips%2Fcrumble","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flsphillips%2Fcrumble/lists"}