{"id":27184211,"url":"https://github.com/marcmartinezdev/storagecart","last_synced_at":"2026-05-19T10:36:07.493Z","repository":{"id":286784866,"uuid":"962537180","full_name":"MarcMartinezDev/storagecart","owner":"MarcMartinezDev","description":"A simple, type-safe shopping cart utility class that persists its data in localStorage.","archived":false,"fork":false,"pushed_at":"2025-04-08T10:07:49.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T05:39:49.881Z","etag":null,"topics":["cart","npm","shop","shopping-cart","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/storagecart","language":"TypeScript","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/MarcMartinezDev.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-04-08T09:53:27.000Z","updated_at":"2025-04-08T10:14:48.000Z","dependencies_parsed_at":"2025-04-08T11:23:40.293Z","dependency_job_id":"1bc670c4-cdad-4f91-9ccf-da1d88e9a95d","html_url":"https://github.com/MarcMartinezDev/storagecart","commit_stats":null,"previous_names":["marcmartinezdev/storagecart"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MarcMartinezDev/storagecart","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcMartinezDev%2Fstoragecart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcMartinezDev%2Fstoragecart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcMartinezDev%2Fstoragecart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcMartinezDev%2Fstoragecart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MarcMartinezDev","download_url":"https://codeload.github.com/MarcMartinezDev/storagecart/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcMartinezDev%2Fstoragecart/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266296815,"owners_count":23907015,"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","status":"online","status_checked_at":"2025-07-21T11:47:31.412Z","response_time":64,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cart","npm","shop","shopping-cart","typescript"],"created_at":"2025-04-09T16:38:19.035Z","updated_at":"2026-05-19T10:36:07.437Z","avatar_url":"https://github.com/MarcMartinezDev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🛒 StorageCart\n\nA simple, type-safe shopping cart utility class that persists its data in `localStorage`. Ideal for frontend applications where you need to manage a cart without a backend.\n\n[https://github.com/MarcMartinezDev/storagecart](https://github.com/MarcMartinezDev/storagecart).\n\n---\n\n## ✨ Features\n\n- 🧠 Fully typed with generics\n- 🔄 Persists cart data in `localStorage`\n- ➕ Add, remove, and update items\n- 💸 Apply discounts and taxes\n- 🧹 Clear cart, check item existence, and get totals\n- ⚡️ Lightweight and dependency-free\n\n---\n\n## 📦 Installation\n\n```bash\nnpm install storagecart\n```\n\n## 📘 API Reference\n\n### `new Cart\u003cT\u003e()`\n\nInitializes the cart and loads any saved items from `localStorage`.\n\n---\n\n### `add(item: T): void`\n\nAdds a new item to the cart or increases its quantity if it already exists.\n\n- **item**: Object of type `T` with at least `id`, `price`, and `quantity` properties.\n\n---\n\n### `remove(id: string | number): void`\n\nRemoves an item from the cart by its ID.\n\n- **id**: The ID of the item to remove.\n\n---\n\n### `less(id: string | number): void`\n\nDecreases the quantity of an item by 1. Removes it if the quantity reaches 0.\n\n- **id**: The ID of the item to decrement.\n\n---\n\n### `more(id: string | number): void`\n\nIncreases the quantity of an item by 1.\n\n- **id**: The ID of the item to increment.\n\n---\n\n### `clear(): void`\n\nEmpties the entire cart and clears the saved data from `localStorage`.\n\n---\n\n### `discount(rate: number): void`\n\nApplies a discount to all items in the cart.\n\n- **rate**: A number between `0` and `1` (e.g., `0.2` for a 20% discount).\n\n---\n\n### `applyTax(rate: number): void`\n\nApplies tax to all item prices in the cart.\n\n- **rate**: A number between `0` and `1` (e.g., `0.21` for 21% VAT).\n\n---\n\n### `hasItem(id: string | number): boolean`\n\nChecks whether an item exists in the cart.\n\n- **id**: The ID of the item.\n\n---\n\n### `isEmpty(): boolean`\n\nReturns `true` if the cart has no items, otherwise `false`.\n\n---\n\n### `getItems(): T[]`\n\nReturns all current items in the cart.\n\n---\n\n### `getProductAmount(id: string | number): number`\n\nReturns the total amount for a specific item (`quantity × price`).\n\n- **id**: The ID of the item.\n\n---\n\n### `getProductQuantity(id: string | number): number`\n\nReturns the quantity of a specific item in the cart.\n\n- **id**: The ID of the item.\n\n---\n\n### `getTotalAmount(): number`\n\nReturns the total cost of all items in the cart.\n\n---\n\n### `getTotalItemCount(): number`\n\nReturns the total number of items (sum of all quantities) in the cart.\n\n## ✅ Requirements\n\nModern browser environment (uses localStorage)\n\nTypeScript support\n\n## Contributing\n\n- Fork the repository.\n\n- Create a new branch (git checkout -b feature-xyz).\n\n- Make your changes.\n\n- Commit your changes (git commit -am 'Add feature XYZ').\n\n- Push to the branch (git push origin feature-xyz).\n\n- Create a new Pull Request.\n\nYou can find the repository on GitHub at [https://github.com/MarcMartinezDev/storagecart](https://github.com/MarcMartinezDev/storagecart).\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcmartinezdev%2Fstoragecart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcmartinezdev%2Fstoragecart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcmartinezdev%2Fstoragecart/lists"}