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

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.

主站蜘蛛池模板: 绥棱县| 樟树市| 中超| 托里县| 高淳县| 灵山县| 大同市| 禄丰县| 奈曼旗| 华容县| 手游| 丹寨县| 鄂托克前旗| 堆龙德庆县| 永嘉县| 德昌县| 宣武区| 安福县| 西昌市| 陵水| 图木舒克市| 德州市| 阆中市| 常德市| 邹平县| 临邑县| 如皋市| 乾安县| 西城区| 陕西省| 广元市| 曲松县| 中卫市| 连南| 天峨县| 昆明市| 晴隆县| 定远县| 锦屏县| 磐石市| 柳州市|