{"id":16346947,"url":"https://github.com/simonsmith/basket-app","last_synced_at":"2026-06-09T16:31:05.923Z","repository":{"id":140934464,"uuid":"80062077","full_name":"simonsmith/basket-app","owner":"simonsmith","description":null,"archived":false,"fork":false,"pushed_at":"2017-01-25T23:35:12.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-05-19T05:05:30.583Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simonsmith.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2017-01-25T21:59:22.000Z","updated_at":"2017-01-26T11:45:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"02226746-084c-40a0-9f67-7b013bb6df20","html_url":"https://github.com/simonsmith/basket-app","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/simonsmith/basket-app","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonsmith%2Fbasket-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonsmith%2Fbasket-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonsmith%2Fbasket-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonsmith%2Fbasket-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonsmith","download_url":"https://codeload.github.com/simonsmith/basket-app/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonsmith%2Fbasket-app/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34116456,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":[],"created_at":"2024-10-11T00:38:46.254Z","updated_at":"2026-06-09T16:31:05.907Z","avatar_url":"https://github.com/simonsmith.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Basket app (test)\n\n## Assumptions\n\n* Items are presented sequentially in an array or as a string\n* One offer per item (this could be extended to support an array of offers)\n* Products and offers are known in advance (these could be stored elsewhere)\n\n## Installation\n\n1. Clone the repo\n1. `yarn` or `npm install`\n1. `yarn test` or `npm test`\n\n\u003e Requires node 6.0.0+ for ES6 compatibility\n\n## Usage\n\n### `add`\n\nAccepts string or array of strings and returns true if successful\n\n```js\nbasket.add(['Apple', 'Orange']);\nbasket.add('Apple');\n```\n\n### `empty`\n\nRemoves all items from the basket\n\n```js\nbasket.empty();\n```\n\n### `getTotal`\n\nReturns the contents of the basket in JSON which is suitable for rendering by a\nview layer like React\n\n```js\nbasket.getTotal();\n```\n\n```json\n{\n  \"items\": [\n    {\n      \"name\": \"Papaya\",\n      \"quantity\": 3,\n      \"price\": \"£1.00\",\n      \"discount\": \"£0.50\"\n    },\n    {\n      \"name\": \"Garlic\",\n      \"quantity\": 2,\n      \"price\": \"£0.30\"\n    },\n    {\n      \"name\": \"Apple\",\n      \"quantity\": 1,\n      \"price\": \"£0.25\"\n    },\n    {\n      \"name\": \"Orange\",\n      \"quantity\": 2,\n      \"price\": \"£0.60\"\n    }\n  ],\n  \"totalPrice\": \"£2.15\",\n  \"totalItems\": 8\n}\n```\n\n## Adding offers\n\nOffers are just functions that receive the `quantity`, `price`, and `total`. The\nvalue returned is used as the discounted price.\n\nAdd new offers to `offers.js`:\n\n```js\nmodule.exports = {\n  someNewOffer(quantity, price, total) {\n    // return a value\n  },\n};\n```\n\nThe function name is used by the product in `products.js`\n\n```js\n{\n  'pears': {price: 25, offer: 'someNewOffer'},\n}\n```\n\nOffers can be added to every product\n\n## TODO\n\nAdding `remove`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonsmith%2Fbasket-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonsmith%2Fbasket-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonsmith%2Fbasket-app/lists"}