From the course: Node.js: Design Patterns

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Implementing the storage class

Implementing the storage class - Node.js Tutorial

From the course: Node.js: Design Patterns

Start my 1-month free trial

Implementing the storage class

- [Instructor] In the last lesson, we added code to the store to use a storage class that implements the chain of responsibility design pattern. In this lesson, we'll code the storage class so that we can search for inventory items in multiple locations. I'm inside of the exercise files for chapter four, chapter four lesson two, and I'm inside of the start folder. Within this folder I'm going to go ahead and add a new file called storage.js. And in our storage file I'm going to go ahead and create a new class, storage, and we'll go ahead and give it a constructor. And this class will take in the name of the storage location and also the inventory for that location. And then finally we also are taking in a delivery time. And I am going to default the delivery time to zero and the inventory to an empty array in case those values are not sent. Those this.name is going to equal our name, this.inventory is going to equal our inventory, and this.deliverytime will equal the delivery time…

Contents