{"id":13760225,"url":"https://github.com/nirtz89/crumbsjs","last_synced_at":"2025-05-10T10:31:59.716Z","repository":{"id":46940768,"uuid":"149968135","full_name":"nirtz89/crumbsjs","owner":"nirtz89","description":"A lightweight vanilla ES6 cookies and local storage JavaScript library","archived":false,"fork":false,"pushed_at":"2024-09-26T21:55:44.000Z","size":1149,"stargazers_count":233,"open_issues_count":11,"forks_count":13,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-11-05T14:06:31.773Z","etag":null,"topics":[],"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/nirtz89.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-23T09:04:07.000Z","updated_at":"2024-08-31T11:00:03.000Z","dependencies_parsed_at":"2023-02-11T07:45:32.457Z","dependency_job_id":null,"html_url":"https://github.com/nirtz89/crumbsjs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nirtz89%2Fcrumbsjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nirtz89%2Fcrumbsjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nirtz89%2Fcrumbsjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nirtz89%2Fcrumbsjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nirtz89","download_url":"https://codeload.github.com/nirtz89/crumbsjs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224949728,"owners_count":17397225,"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":[],"created_at":"2024-08-03T13:01:05.655Z","updated_at":"2024-11-16T17:30:50.371Z","avatar_url":"https://github.com/nirtz89.png","language":"JavaScript","funding_links":[],"categories":["Storage","Storage [🔝](#readme)","存储"],"sub_categories":["Runner","运行器","运行器e2e测试"],"readme":"## 🍪 CrumbsJS 🍪\n\nA lightweight, intuitive, vanilla ES6 fueled JS cookie and **local storage** library.\n\n## Quick Start\n\n### Adding a single cookie or a local storage key\n```javascript\n// Cookie\ncrumbs.set(\"Operating System\",\"Win10\"); // =\u003e true\n\n// Local storage key\ncrumbs.ls.set(\"Operating System\",\"Win10\") // =\u003e true\n```\n\n### Adding a single cookie that will expire in 7 days for a specific path\n```javascript\n// The \"expires\" parameter is capable of taking a number, and will default as days.\ncrumbs.set(\"Name\",\"Roy Azaeev\",{type:\"day\",value:7},\"/crumbsjs\"); // =\u003e true\n```\n\n### Adding a few cookies at once\n```javascript\nconst my_cookies = [];\nmy_cookies.push({name:\"Operating System\",value:\"Win10\"});\nmy_cookies.push({name:\"Age\",value:\"29\"});\n\ncrumbs.set(my_cookies); // =\u003e [{name:\"Operating System\",value:\"Win10\"},{name:\"Age\",value:\"29\"}]\n```\n\n### Adding a few local storage keys at once\n```javascript\nconst my_localstorage_array = [];\nmy_localstorage_array.push({\"key\":\"Operating System\",\"value\":\"Win10\"});\nmy_localstorage_array.push({\"key\":\"Age\",\"value\":\"29\"});\n\ncrumbs.ls.set(my_localstorage_array); // =\u003e [{key:\"Operating System\",value:\"Win10\"},{key:\"Age\",value:\"29\"}]\n```\n\n### Get a cookie or a local storage key value\n```javascript\n// Cookie\nlet age = crumbs.get(\"Age\"); // =\u003e \"29\"\n\n// Local storage\nlet age = crumbs.ls.get(\"Age\"); // =\u003e \"29\"\n```\n\n### Get all cookies or all local storage keys in a key-value pair object\n```javascript\n// Cookies\nlet all_cookies = crumbs.getAll(); // =\u003e [{name:\"Operating System\",value:\"Win10\"},{name:\"Age\",value:\"29\"}]\n\n// Local storage\nlet all_localstorage = crumbs.ls.getAll(); // =\u003e [{key:\"Operating System\",value:\"Win10\"},{key:\"Age\",value:\"29\"}]\n```\n\n### Delete a single cookie or local storage key\n```javascript\n// Cookie\ncrumbs.delete(\"Operating system\"); // =\u003e true\n\n// Local storage\ncrumbs.ls.delete(\"Operating system\"); // =\u003e true\n```\n\n### Delete a few cookies at once\n```javascript\nconst my_cookies = [];\nmy_cookies.push(\"Operating system\");\nmy_cookies.push(\"Age\");\n\ncrumbs.delete(my_cookies); // =\u003e true\n```\n\n## Features\n\n* **NO DEPENDENCIES** - Yup, no jQuery.\n* ES5 compatible.\n* Tested, using Jest.\n* Add one or multiple cookies or local storage keys at once\n* Update cookies or local storage keys using the `set` method\n* Delete one or multiple cookies at once\n* Delete local storage keys easily\n* Display a cookie or a local storage key value\n* Display all cookies or local storage keys in a key-value easy to read object\n* Fallback to cookies when localstorage is not available (Safari private browsing)\n\n\n## Methods\n\n### set(name, value, [expires], [domain])\nSets one or more cookies or local storage keys.\n\u003e name can be set as an array of key-pair objects in the format of {name:\"Age\",value:29} for mass cookie set\n\n---\n\n### get(name)\nGets a cookie or a local storage value by its name.\n\n---\n\n### getAll()\nGets all the cookies or local storage keys in a key-pair object array.\n\n---\n\n### delete(name)\nDeletes a cookie or local storage key by its name.\n\n\u003e name can be set as an array of strings for mass delete of cookies\n---\n\n### deleteAll()\nDeletes all cookies or local storage keys.\n\n\n## Getting Started\n\n### Install On your local PC\n\n#### Using a bundler ?\n\nYou can import CrumbsJS like that\n\n```js\nimport crumbs from 'crumbsjs';\n```\n\n#### Download Sources\n\nuse npm\n\n```bash\nnpm install crumbsjs\n```\n\nuse git\n\n```bash\ngit clone https://github.com/nirtz89/crumbsjs.git\n```\n\n## What's next\n* IndexDB support\n* Session storage support\n\n## Contributers\n\n![alt text](https://avatars3.githubusercontent.com/u/1689750?s=60\u0026v=4 \"Johann-S\") ![alt text](https://avatars1.githubusercontent.com/u/15731984?s=60\u0026v=4 \"Swiftmatt\") ![alt text](https://avatars1.githubusercontent.com/u/12184996?s=60\u0026v=4 \"4marcellefter\") ![alt text](https://avatars.githubusercontent.com/u/9419680?s=60\u0026v=4 \"pablogiralt\")\n\nThank you for making the library better!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnirtz89%2Fcrumbsjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnirtz89%2Fcrumbsjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnirtz89%2Fcrumbsjs/lists"}