File
Blob: samples/extensions/burrito-shop-impl.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 | // burrito-shop-impl is an internal module and can't be imported by user code |
| 6 | |
| 7 | |
| 8 | // internal modules can import each other, but users still can't access them |
| 9 | import { makeBurritoImpl } from "burrito-shop-internal:kitchen"; |
| 10 | |
| 11 | export class BurritoShop { |
| 12 | #recipes; |
| 13 | |
| 14 | constructor(recipes) { |
| 15 | this.#recipes = recipes; |
| 16 | } |
| 17 | |
| 18 | makeBurrito(type) { |
| 19 | if (!(type in this.#recipes)) { |
| 20 | throw new Error(`recipe not found: ${type}`); |
| 21 | } |
| 22 | return makeBurritoImpl(this.#recipes[type]); |
| 23 | } |
| 24 | } |