Node.js Design Patterns by Mario Casciaro && Luciano Mammino

Node.js Design Patterns by Mario Casciaro && Luciano Mammino

Author:Mario Casciaro && Luciano Mammino
Language: eng
Format: epub
Tags: COM051260 - COMPUTERS / Programming Languages / JavaScript, COM060180 - COMPUTERS / Web / Web Services & APIs, COM060160 - COMPUTERS / Web / Web Programming
Publisher: Packt
Published: 2020-07-23T12:39:56+00:00


This is what's happening in the preceding code:

In the constructor, we create an instance variable called data to hold the configuration data. Then we also store formatStrategy, which represents the component that we will use to parse and serialize the data.

We provide two methods, set() and get(), to access the configuration properties using a dotted path notation (for example, property.subProperty) by leveraging a library called object-path (nodejsdp.link/object-path).

The load() and save() methods are where we delegate, respectively, the deserialization and serialization of the data to our strategy. This is where the logic of the Config class is altered based on the formatStrategy passed as an input in the constructor.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.