官术网_书友最值得收藏!

Summary

In this chapter, you learned that parsing in process.argv can be a real pain. We would have to write a lot of manual code to parse out those hyphens, the equal signs, and the optional quotes. However, yargs can do all of that for us and it puts it on a really simple object we can access. You also learned how to work with JSON inside Node.js.

Next, we filled out the addNote function. We're able to add notes using the command line, and we're able to save those notes into a JSON file. Finally, we pulled out a lot of the code from addNote into separate functions, fetchNotes and saveNotes, which are now separate, and they're able to be reused throughout the code. When we start filling out the other methods, we can simply call fetchNotes and saveNotes instead of having to copy the contents over and over again to every new method.

In the next chapter, we'll continue our journey on node fundamentals. We'll explore some more concepts related to node, such as debugging; we'll work on the read and remove notes commands. Apart from this, we'll also learn about the advanced features of yargs and the arrow function.

主站蜘蛛池模板: 伊春市| 富蕴县| 彭水| 连云港市| 梁山县| 淮安市| 哈密市| 福建省| 枝江市| 溧水县| 攀枝花市| 吉水县| 任丘市| 富源县| 瓦房店市| 永宁县| 宝应县| 石渠县| 嘉黎县| 汾阳市| 湘潭县| 永善县| 荣昌县| 澄城县| 昭苏县| 基隆市| 静海县| 巨鹿县| 页游| 昌黎县| 固安县| 垫江县| 仙居县| 崇明县| 昂仁县| 光泽县| 台安县| 马边| 新乡县| 许昌县| 临夏县|