File
Blob: samples/extensions/kitchen.js
| 1 | // Copyright (c) 2023 Cloudflare, Inc. |
| 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: |
| 3 | // https://opensource.org/licenses/Apache-2.0 |
| 4 | |
| 5 | // kitchen.js is an internal module and can't be imported by user code. |
| 6 | |
| 7 | const prices = { "rice": 1, "meat": 5, "beans": 1, "cheese": 1, "salsa": 1, "guacamole": 6, }; |
| 8 | |
| 9 | class Burrito { |
| 10 | #recipe; |
| 11 | constructor(recipe) { |
| 12 | this.#recipe = recipe; |
| 13 | } |
| 14 | |
| 15 | price() { |
| 16 | return this.#recipe.reduce((acc, val) => acc + prices[val], 0); |
| 17 | } |
| 18 | }; |
| 19 | |
| 20 | export function makeBurritoImpl(recipe) { |
| 21 | return new Burrito(recipe); |
| 22 | } |