{"id":13669742,"url":"https://github.com/XadillaX/nyaa-nodejs-demo","last_synced_at":"2025-04-27T08:32:52.055Z","repository":{"id":50630665,"uuid":"88426130","full_name":"XadillaX/nyaa-nodejs-demo","owner":"XadillaX","description":"Source code of \"Node.js: Let's Write a Dozen of C++ Add-ons\". 《Node.js：来一打 C++ 扩展》随书源码。","archived":false,"fork":false,"pushed_at":"2022-04-11T01:59:08.000Z","size":729,"stargazers_count":375,"open_issues_count":0,"forks_count":68,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-04-13T22:32:27.444Z","etag":null,"topics":["book-source-code","cpp-addon","nodejs","nodejs-cpp-addon"],"latest_commit_sha":null,"homepage":"http://nyaanode.2333.moe/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/XadillaX.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-16T16:01:43.000Z","updated_at":"2024-03-22T05:36:36.000Z","dependencies_parsed_at":"2022-09-13T21:11:10.325Z","dependency_job_id":null,"html_url":"https://github.com/XadillaX/nyaa-nodejs-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XadillaX%2Fnyaa-nodejs-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XadillaX%2Fnyaa-nodejs-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XadillaX%2Fnyaa-nodejs-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XadillaX%2Fnyaa-nodejs-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/XadillaX","download_url":"https://codeload.github.com/XadillaX/nyaa-nodejs-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251112602,"owners_count":21538162,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["book-source-code","cpp-addon","nodejs","nodejs-cpp-addon"],"created_at":"2024-08-02T09:00:21.023Z","updated_at":"2025-04-27T08:32:49.070Z","avatar_url":"https://github.com/XadillaX.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"# 《Node.js：来一打 C++ 扩展》随书源码\n\n![封面](cover.jpg)\n\n[English Document](README_en.md)\n\n本仓库为死月所著《Node.js：来一打 C++ 扩展》的随书源码，大家尽情享用。\n\n\u003e **注意**：所有的随书代码均在 macOS 命令行下 Node.js 6.x 测试通过。理论上，它们也可以在 Windows 和 UNIX 上运行良好，但我并没有验证过。\n\n## 下载\n\n本源码可从博文视点官方网站上下载。如果你对 [Git](https://git-scm.com/) 熟悉，且愿意使用 Git 克隆本仓库使用源码，非常欢迎。\n\n如果需要克隆本仓库，可以使用以下命令行：\n\n```shell\n$ git clone https://github.com/XadillaX/nyaa-nodejs-demo.git --recurse-submodules\n```\n\n\u003e `--recurse-submodules` 参数允许你连通 submodule 一起克隆下来。\n\u003e\n\u003e 由于 GitHub 的特性，如果你直接从 GitHub 的本页面上直接通过 **Download ZIP** 链接下载压缩包，将不会包含一些必要依赖的 submodule。所以如果你想通过压缩包下载的形式获取源码，请转到博文视点官方网站。\n\n## 快速导航\n\n1. [first build](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/1.%20first%20build)：「1.4.2. node-gyp」\n2. [cpp entry](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/2.%20cpp%20entry)：「2.2.2. Node.js 模块加载原理」\n3. [function template](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/3.%20function%20template)：「3.6.1. 函数模板（Function Template）」\n4. [object template](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/4.%20object%20template)：「3.6.2. 对象模板（Object Template）」\n5. [object template accessor](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/5.%20object%20template%20accessor)：「3.6.3. 对象模板的访问器（Accessor）与拦截器（Interceptor）」\n6. [mapped property interceptor](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/6.%20mapped%20property%20interceptor)：「3.6.3. 对象模板的访问器（Accessor）与拦截器（Interceptor）」\n7. [indexed property interceptor](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/7.%20indexed%20property%20interceptor)：「3.6.3. 对象模板的访问器（Accessor）与拦截器（Interceptor）」\n8. [internal field wrong](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/8.%20internal%20field%20wrong)：「3.6.4. 对象模板的内置字段（Internal Field）」\n9. [internal field right](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/9.%20internal%20field%20right)：「3.6.4. 对象模板的内置字段（Internal Field）」\n10. [function template inherit](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/10.%20function%20template%20inherit)：「3.6.5. 函数模板的继承（Inherit）」\n11. [array prototype map](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/11.%20array%20prototype%20map)：「3.7.6. 函数（Function）」\n12. [try catch](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/12.%20try%20catch)：「3.8.1. Try-Catch」\n13. [hello world again](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/13.%20hello%20world%20again)：「4.2.1. 又是 Hello World」\n14. [function parameters](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/14.%20function%20parameters)：「4.2.2. 函数参数」\n15. [run callback](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/15.%20run%20callback)：「4.2.3. 回调函数」\n16. [object factory](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/16.%20object%20factory)：「4.2.4. 对象返回」\n17. [function factory](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/17.%20function%20factory)：「4.2.5. 函数返回」\n18. [myobject](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/18.%20myobject)：「4.3.1. C++ 与 JavaScript 类封装」\n19. [at_exit_hook](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/19.%20at_exit_hook)：「4.3.4. 进程退出钩子」\n20. [nan echo](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/20.%20nan%20echo)：「5.2.3. 来不及解释了，先上车」\n21. [nan array prototype map](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/21.%20nan%20array%20prototype%20map)：「5.2.4. 基础帮助函数和宏」\n22. [nan set method](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/22.%20nan%20set%20method)：「5.3.3. 函数设置」\n23. [nan reverse string](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/23.%20nan%20reverse%20string)：「5.4.3. 与数据对象“玩耍”」\n24. [nan object demo](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/24.%20nan%20object%20demo)：「5.4.3. 与数据对象“玩耍”」\n25. [nan array demo](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/25.%20nan%20array%20demo)：「5.4.3. 与数据对象“玩耍”」\n26. [nan json](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/26.%20nan%20json)：「5.4.3. 与数据对象“玩耍”」\n27. [nan buffer](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/27.%20nan%20buffer)：「5.4.3. 与数据对象“玩耍”」\n28. [nan nbodies](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/28.%20nan%20nbodies)：「5.5.3. Nan::AsyncWorker」\n29. [nan dummy download](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/29.%20nan%20dummy%20download)：「5.5.4. Nan::AsyncProgressWorker」\n30. [libuv idle](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/30.%20libuv%20idle)：「6.1.3. 尝个甜头」\n31. [libuv sleep sort](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/31.%20libuv%20sleep%20sort)：「6.2.1. libuv 的线程」\n32. [libuv sleep sort advanced](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/32.%20libuv%20sleep%20sort%20advanced)：「6.2.2. 同步原语（Synchronization Primitives）」\n33. [libuv watchdog](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/33.%20libuv%20watchdog)：「6.3.2. Watchdog 半成品实战解析」\n34. [efsw](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/34.%20efsw)：「7.1.1. 功能规划」\n35. [efsw advanced](https://github.com/XadillaX/node-efsw/tree/85cc5b816c3e04b4df92f63592f5e9ce99808418)：「7.4.2. JavaScript 代码完善」\n36. [napi](https://github.com/XadillaX/nyaa-nodejs-demo/tree/master/36.%20napi)：「9.1.1. 实现一个 `Echo` 函数」\n\n## 购书链接\n\n+ [京东](https://item.jd.com/12380404.html)\n+ [天猫](https://detail.tmall.com/item.htm?id=571628730908\u0026cat_id=2)\n+ [当当](http://product.dangdang.com/25291814.html)\n+ [亚马逊](https://www.amazon.cn/dp/B07DL8GHQC/ie=UTF8\u0026qid=1528969734)\n+ [china-pub](http://product.china-pub.com/8039217)\n+ [豆瓣](https://book.douban.com/subject/30247892/)（不算购书链接）\n\n## QQ 交流群\n\n\u003cimg src=\"./qq_group.jpg\" width=\"200\" alt=\"QQ 群\" /\u003e\n\n## 感谢阅读\n\n最后，感谢大家支持本书。\n\n![フランドール・スカーレット](flandre.jpg)\n\n\u003ccenter\u003e\u003cfont color=\"gray\"\u003e\u003csmall\u003e图片来自 \u003ca target=\"_blank\" href=\"https://www.pixiv.net/member_illust.php?mode=medium\u0026illust_id=35873732\"\u003ePixiv\u003c/a\u003e\u003c/small\u003e\u003c/font\u003e\u003c/center\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FXadillaX%2Fnyaa-nodejs-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FXadillaX%2Fnyaa-nodejs-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FXadillaX%2Fnyaa-nodejs-demo/lists"}