å幎åãç§ã¯ãæ¬ãæžããŸããïŒããšæã£ãŠããããæžããŸããã
ãã¹ãŠã®ããã¥ã¡ã³ããå®è¡ãããããŒãžãã¬ã€ã¢ãŠããããå°å·å®è¡ãå°å·ãããŸãã ããã¯ã¹ã¿ãŒã¿ãŒã«ãéãé Œãããšããäœããè²·ãããšãç³ãåºãããšããããŸãããã代ããã«ãåºå ±ã®ããã®NodeJSã®éçºã®ãã³ãã«èå³ãæã¡ãæ¬ã«æ³šç®ããŠãã ããã
ãã³ã1. SQLã¯ãšãªã¯ããã©ãŒããããç¶æããã®ãæé©ã§ãã
SQLã¯ãšãªããã©ãŒãããããŠä¿åããããšããå§ãããŸãã ãã®å Žåã®ã³ãŒãã¯ãèªã¿åããšç·šéãã¯ããã«ç°¡åã§ãã ãªããªã éåžžãSQLã¯ãšãªã¯éåžžã«é·ããè€æ°ã®è¡ã«åå²ããæ¹ãé©åã§ããJavaScriptã®è¡ã¯é åã§æé©ã«èŠããŸãã
å®å ïŒ
var query = "SELECT g.id, g.title, g.description, g.link, g.icon, t.id as tag_id, c.title as comment_title FROM games AS g LEFT JOIN tags AS t ON t.game_id = g.id LEFT JOIN comments AS c ON c.game_id = g.id WHERE g.id = $1";
åŸïŒ
var query = [ "SELECT ", " g.id, g.title, g.description, g.link, g.icon, ", " t.id as tag_id, c.title as comment_title ", " FROM games AS g ", " LEFT JOIN tags AS t ON t.game_id = g.id ", " LEFT JOIN comments AS c ON c.game_id = g.id ", " WHERE ", " g.id = $1" ];
2çªç®ã®ã±ãŒã¹ã§ã¯ãèªè ã«ãšã£ãŠãªã¯ãšã¹ããã¯ããã«æ確ã§ããããšã«åæããŸãã ããã«ãããŒã¿ããŒã¹ãžã®ãªã¯ãšã¹ãã®åã«ã³ã³ãœãŒã«ã«ã¯ãšãªãåºåãããšãconsole.dirïŒïŒã§ã¹ããŒãããé åã¯ãconsole.logïŒïŒã§ã¹ããŒãããæååãããã¯ããã«æ確ã«ãªããŸãã
ãã³ã2.ããŸããŸãªã³ã³ããŒãã³ãã®APIãä»»æã®åœ¢åŒãå ¥åãšããŠåãå ¥ãããšãäœæ¥ã楜ã«ãªããŸãã
ããŒã¿ããŒã¹ã®ã¯ã©ã€ã¢ã³ããäœæããç¹å®ã®SQLã¯ãšãªãå®è¡ãããšããŸãã å ¥åã§ã¯ãæååãšãã©ã¡ãŒã¿ãŒãå¿ èŠã§ãã ãªããªã é·ãã¯ãšãªãé åã«æ ŒçŽããããšã«ããæåŸã®ãã³ãã䜿çšããŠãåã¯ãšãªã§æååã«å€æããããšãå¿ããããšæããŸãã
å®å ïŒ
dataBase(query.join(""), parameters, callback);
åŸïŒ
dataBase(query, parameters, callback);
ããŒã¿ããŒã¹ã¯ãšãªé¢æ°ïŒãã®å Žåã¯dataBaseïŒãããªã¯ãšã¹ããéä¿¡ããã圢åŒã§èªèº«ããã§ãã¯ãããããé åã®å Žåãããèªäœãçµåãããšãã«ãã³ãŒãã¯ããåçŽã«ãªããŸãïŒïŒã
ãã³ã3.ã³ã³ãœãŒã«ã«è²ãä»ããŠåºåããã©ãŒããããã
NodeJSã®åæ¹ããã°ã©ã ã¯é£ããããã ããã¬ãŒã¯ãã€ã³ãããªã©ã®ãã¹ãŠã®ããããåããæšæºéçºè ã³ã³ãœãŒã«ã¯éåžžã«äžè¶³ããŠããŸãã ãã¹ãŠã®ããŒã¿ã¯ã³ã³ãœãŒã«ã«æžã蟌ãŸããã®ã§ãããããããããããšæããŸãã ããŒãããµãŒããŒäžã®ã©ããã§ãè€æ°ã®ã€ã³ã¹ã¿ã³ã¹ã§ãããã«ã¯åã€ã³ã¹ã¿ã³ã¹ã§è€æ°ã®ç°ãªããµãŒãã¹ã§ããããã³ã°ããSSHçµç±ã§ã®ã¿ã¢ã¯ã»ã¹ã§ããå Žåãã³ã³ãœãŒã«ã¯æ¬åœã«ããªããèŠãããŸãã
NodeJSã§ãHello worldïŒããšãã圢åŒã®æååãã³ã³ãœãŒã«ã«åºåããå ŽåãANSIå¶åŸ¡æåã䜿çšãããšãããŸããŸãªè²ã§ãã€ã³ããããŸãã ANSIå¶åŸ¡æåã®äœ¿çšäŸïŒ
ãã®ãããªãããã³ã°ãèŠããªãããã«ããã«ã¯ãcolorsã¢ãžã¥ãŒã«ãæ¥ç¶ããŠã次ã®æ§æã䜿çšã§ããŸãã
console.log("Error! Parameter ID not found.".red);
æååã¯èµ€ã§è¡šç€ºãããŸãã ãã®ã¢ãžã¥ãŒã«ã䜿çšããŠéçºããå Žåãã³ã³ãœãŒã«å ã®ã¡ãã»ãŒãžãããŸããŸãªè²ã«è²ä»ãã§ããŸãã
- èµ€ïŒãšã©ãŒïŒã
- é»è²ïŒèŠåïŒã
- ç·ïŒãã¹ãŠé 調ïŒã
- ç°è² ãšã©ãŒããã£ãããããŸã§æ³šæãæããªããã©ã¡ãŒã¿ãŒïŒã¯ãšãªãã©ã¡ãŒã¿ãŒãªã©ïŒã衚瀺ã§ããŸãã
è²ã匷調衚瀺ããåã®ã³ã³ãœãŒã«ïŒãã°ãã衚瀺ããå Žåãæ å ±ã¯é£ãªãç¥èŠãããŸãïŒïŒ
è²ã®åŒ·èª¿è¡šç€ºåŸã®ã³ã³ãœãŒã«ïŒãã°ãã衚瀺ãããšãæ å ±ãéåžžã«ãã°ããèªèãããŸãïŒïŒ
è²ä»ãã®ã³ã³ãœãŒã«ã®ãããã§ããµãŒããŒã®ã¹ããŒã¿ã¹ãç£èŠããã®ãã¯ããã«ç°¡åã«ãªããŸãã ããã«ã1ã€ã®ã€ã³ã¹ã¿ã³ã¹ã«ç°ãªãããã»ã¹ã§åäœããè€æ°ã®ãµãŒãã¹ãããå Žåãã³ã³ãœãŒã«ãžã®åºåçšã«ã¢ãžã¥ãŒã«ã«åå¥ã®ã¡ãœãããèšè¿°ããå¿ èŠããããŸãã äŸïŒ
var book = { console: function(message, color) { console.log(("Book API: " + (message || ""))[(color || white")]); } }
ã³ã³ãœãŒã«å ã®ãã¹ãŠã®ã¡ãã»ãŒãžãããããéä¿¡ããã¢ãžã¥ãŒã«ã«ãã£ãŠçœ²åãããŠããå Žåãç¹å®ã®ã¢ãžã¥ãŒã«ãéžæã§ããã ãã§ãªããé倧ãªç¶æ³ã®ãã°ã®ãœãŒã¹ãå³åº§ã«èŠã€ããããšãã§ããŸãã ããã¹ãã®æžåŒèšå®ã«ãããæ å ±ã®èªèãç°¡çŽ åãããŸãã
ãããã£ãŠãã³ã³ãœãŒã«ã®ãã¹ãŠã®æ å ±ã眲åãããç¹å®ã®ã¢ãžã¥ãŒã«ã§çºçããã€ãã³ããç°¡åã«ç解ã§ããŸãã ç¹°ãè¿ãã«ãªããŸãããç¹å®ã®ã·ã¹ãã ã«é害ãçºçããŠç·æ¥ã«ä¿®æ£ããå¿ èŠãããããã°ãèªãæéããªãå Žåãã¹ãã¬ã¹ã®å€ãç¶æ³ã§è²ã®åŒ·èª¿è¡šç€ºã圹ç«ã¡ãŸãïŒå®çšŒåç°å¢ããããã°ããããšã¯ãå§ãããŸããã ç§ã®ãããžã§ã¯ãã§ã¯ããã¹ãŠã®ã€ã³ã¹ã¿ã³ã¹ã«èªåçã«çœ²åããã ãã§ãªããæååã ãã§ãªãé åããªããžã§ã¯ãã«ãè²ãä»ããããšãã§ããããã«ãã³ã³ãœãŒã«ã¢ãžã¥ãŒã«ãæžãçŽãããšã«ããŸããã ãããã£ãŠãã¢ãžã¥ãŒã«ãæ¥ç¶ãããšãã«ãã¡ãã»ãŒãžã«çœ²åããããã±ãŒãžã®ååãæž¡ããŸãã æ°ããã³ã³ãœãŒã«ã¢ãžã¥ãŒã«ã®äœ¿çšäŸïŒ
var console = require("./my_console")("Scoring SDK"); console.green("Request for DataBase."); console.grey([ "SELECT *", " FROM \"ScoringSDK__game_list\"", " WHERE key = $1;" ]);
ã³ã³ãœãŒã«ãžã®ããŒã¿åºåã®äŸïŒ
ãã³ã4.ãã¹ãŠã®APIãtry / catchã§ã©ãããã
ãšã¯ã¹ãã¬ã¹ãã¬ãŒã ã¯ãŒã¯ã䜿çšããŠããŸãã æšæºã«ãŒã¿ãŒãªããžã§ã¯ãã«ã¯try / catchã©ãããŒããªãããšãããã£ããšããç§ã¯é©ããŸããã äŸïŒ
- æ²ç·ã¢ãžã¥ãŒã«ãæžããŸãã
- 誰ããURLã§ãããåŒã£åŒµã£ã
- ãµãŒããŒãã¯ã©ãã·ã¥ããŸãã
- WTFïŒïŒ
ãããã£ãŠãåžžã«å€éšã¢ãžã¥ãŒã«APIãtry / catchã§ã©ããããŸãã äœããããŸããããªããŠããå°ãªããšãã«ãŒãã¢ãžã¥ãŒã«ãã·ã¹ãã å šäœãå§åããããšã¯ãããŸããã ãã³ãã¬ãŒããéžæãã䜿çšããã¯ã©ã€ã¢ã³ãäžã®åãç¶æ³ïŒããªã¹ããŒãšãããªãã·ã£ãŒããšãåŒã°ããŸãïŒã äŸïŒ
- ã¢ãžã¥ãŒã«Aãæçš¿ãæçš¿ããŸããã
- ã¢ãžã¥ãŒã«BãšCã¯ãããèããŠå¿çããã¯ãã§ãã
- ã·ã¹ãã ã¯ãå å ¥è ãã«ãŒãã§ã«ãŒããå§ããŸãã
- ã¢ãžã¥ãŒã«Bã¯ãšã©ãŒã§ã¯ã©ãã·ã¥ããŸãã
- ãµã€ã¯ã«ã¯äžæããã¢ãžã¥ãŒã«Bã®ã³ãŒã«ããã¯é¢æ°ã¯åŒã³åºãããŸããã
try / catchæ€çŽ¢ãå®è¡ããæ¹ãã¯ããã«åªããŠãããã¢ãžã¥ãŒã«Bãå®éã«ãšã©ãŒã§ã¯ã©ãã·ã¥ããå Žåãå°ãªããšãã·ã¹ãã ã匷å¶çµäºããããšã¯ãªããã¢ãžã¥ãŒã«Cã¯ã€ãã³ããèããåŸã«ãžã§ããå®è¡ããŸãã
ãªããªã APIã¢ãžã¥ãŒã«ãäœæãããšãããã©ã€ããŒãã¡ãœãããšãããªãã¯ã¡ãœãããäœåºŠãåé¢ããå¿ èŠãããããã¹ãŠã®ãããªãã¯ã¡ãœãããtry / catchã§ã©ããããåŸããã®ããžãã¹ãèªååããããšã決å®ããAPIèªåçæçšã®å°ããªã¢ãžã¥ãŒã«ãäœæããŸããã ããšãã°ããã©ãŒã ã®ãªããžã§ã¯ããã¹ããŒããŸãïŒ
var a = { _b: function() { ... }, _c: function() { ... }, d: function() { ... } }
ã¡ãœããã®åœåãããæåã®2ã€ã¯ãã©ã€ããŒãã§ãæåŸã®ã¡ãœããã¯ãããªãã¯ã§ããããšã¯æããã§ãã ã¢ãžã¥ãŒã«ã¯ãåŸè ãåŒã³åºãã©ãããŒãäœæããŸãã圢åŒã¯æ¬¡ã®ãšããã§ãã
var api = { d: function() { try { return ad(); } catch(e) { return false; } } };
ãããã£ãŠããã¹ãŠã®ã¢ãžã¥ãŒã«ã®APIã®ã©ãããŒãçæãå§ããŸããããšã©ãŒãçºçããå Žåãããã¯ãã以äžæž¡ãããŸããã§ããã ããã«ãããã³ãŒããããå®å®ããŸãã æ¬çªç°å¢ã«ããŒãžãããåã ã®éçºè ã®ãšã©ãŒã«ããããµãŒããŒã®ãã¹ãŠã®æ©èœãåé€ãããããšã¯ãªããªããŸããã
APIçæã®äŸïŒ
var a = { _b: function() { ... }, _c: function() { ... }, d: function() { ... } } var api = api.create(a); api.d(); //
ãã³ã5.æ§æã§èŠæ±ãåéãã
ãã¹ãŠã®Webéçºè ã¯ããµãŒããŒäžã®ããŒã¿ããŒã¹ãæäœããããã«å°ããªAPIãå¿ èŠãšããèã£ããã¯ã©ã€ã¢ã³ããããç¶æ³ã«ãã£ããšæããŸãã ããã€ãã®èªã¿åãèŠæ±ãããã€ãã®æžã蟌ã¿èŠæ±ãããã³æ å ±ãåé€ããããã®ããã€ãã®èŠæ±ã éåžžããã®ãããªãµãŒããŒã«ã¯ããžãã¯ã¯ãªããã¯ãšãªã®ã³ã¬ã¯ã·ã§ã³ã«ãããŸããã
ãã®ãããªæäœã®ã©ãããŒãæ¯åäœæããªãããã«ããã¹ãŠã®ãªã¯ãšã¹ããJSONã§äœæãããã®JSONãæäœããããã®APIãæäŸããå°ããªã¢ãžã¥ãŒã«ãšããŠãµãŒããŒãèšèšããããšã«ããŸããã
Expressã§ã®ãã®ãããªã¢ãžã¥ãŒã«ã®äŸïŒ
var fastQuery = require("./fastQuery"), API = fastQuery({ scoring: { get: { query: "SELECT * FROM score LIMIT $1, $2;" parameters: [ "limit", "offset" ] }, set: { query: "INSERT INTO score (user_id, score, date) VALUES ...", parameters: [ "id", "score" ] } }, profile: { get: { query: "SELECT * FROM users WHERE id = $1;", parameters: [ "id" ] } } });
ã¢ãžã¥ãŒã«ãJSONãä»ããŠå®è¡ãããã¯ãšãªãšãã©ã¡ãŒã¿ãŒã®ããããã£ãæã€ãªããžã§ã¯ããæ€çŽ¢ããããšãæ¢ã«æšæž¬ããŠããã§ãããã ãã®ãããªãªããžã§ã¯ããèŠã€ãã£ãå Žåã圌ã¯ãããã®ããã®é¢æ°ãäœæãããã©ã¡ãŒã¿ãŒããã§ãã¯ãããªã¯ãšã¹ããšãšãã«ããŒã¿ããŒã¹ã«ã¢ã¯ã»ã¹ããçµæãã¯ã©ã€ã¢ã³ãã«éä¿¡ããŸãã åºåã§ã¯ã次ã®APIãååŸããŸãã
API.scoring.get(); API.scoring.set(); API.profile.get();
ãããŠããããã«ãŒã¿ãŒãªããžã§ã¯ãã«ãã€ã³ãããŸãã
exports.initRoutes = function (app) { app.get("/scoring/get", API.scoring.get); app.put("/scoring/set", API.scoring.set); app.get("/profile/get", API.profile.get); }
ãã®ç®çã®ããã«ãã¬ãŒã ã¯ãŒã¯ãå®è¡ããŸããã ãµãŒããŒäžã®ãã¯ãããžãŒã¹ã¿ãã¯ã¯äŒæ¥ã«ãã£ãŠç°ãªããŸãã ãã®ãããªãªããžã§ã¯ãã䜿çšããã«ã¯ããããã«ããŠãããªã¯ãšã¹ããåŠçããŠããŒã¿ããŒã¹ãæäœããããã«ãäœãã®äžã«å°ããªãã€ã³ãã£ã³ã°ãèšè¿°ããå¿ èŠããããŸãã ããã«ããããããããã®è¡ãèªãã æç¹ã§ããã®ã¿ã¹ã¯ã®ããã®æ¢è£œã®ãã¬ãŒã ã¯ãŒã¯ããã§ã«ããã€ãããã§ãããã
ããã«2人ã®ãµãŒããŒéçºè ããããšæ³åããŠãã ããã 1ã€ã¯PHPã§èšè¿°ãã2ã€ç®ã¯Javaã§èšè¿°ããŸãã ããŒã¿ããŒã¹ã¯ãšãªã®ãªã¹ãã䜿çšããŠããã®ãããªJSONã ãã«ãã¹ãŠã®ãµãŒããŒããžãã¯ãå¶éããŠããå Žåã¯ãåæ§ã®APIãå¥ã®ãã·ã³ã ãã§ãªããå®å šã«ç°ãªãèšèªã§ãå³åº§ã«è»¢é/ãããã€ã§ããŸãïŒã¯ã©ã€ã¢ã³ããšã®éä¿¡ãæšæºåãããŠããŠã REST APIãä»ããŠéä¿¡ããŸãïŒã
ãã³ã6. configsã§ãã¹ãŠãåãåºã
ãªããªã ç§ã¯èšå®ãæžãããã®ã§ãããã·ã¹ãã ã«æšæºèšå®ãç¹å®ã®ã±ãŒã¹ã®èšå®ãç¹å®ã®æç¹ã§çºçããèšå®ããããšããç¶æ³ãç¹°ãè¿ãçºçããŸããã ç°ãªãJSONãªããžã§ã¯ããæ··åšãããªããã°ãªããŸããã§ããã ãããã®ç®çã®ããã«å¥ã®ã¢ãžã¥ãŒã«ãå²ãåœãŠãããšã«ããŸããããåæã«ãã¡ã€ã«ããJSONãªããžã§ã¯ããååŸããæ©èœãè¿œå ããŸããã èšå®ãå¥ã®jsonãã¡ã€ã«ã«ä¿åããããšãéåžžã«äŸ¿å©ã§ãã ãããã£ãŠãäœãã®èšå®ãè¡ãå¿ èŠãããã®ã§ã次ã®ããã«æžããŸãã
var data = config.get("config.json", "save.json", { name: "Petr", age: 12 });
ãæ³åã®ãšãããã¢ãžã¥ãŒã«ã¯æž¡ãããåŒæ°ãå埩åŠçããŸãã ãããè¡ã®å Žå-ãªããžã§ã¯ãã®å Žåã¯ããã¡ã€ã«ãéããŠèšå®ãèªã¿åãããšããŸã-ãã®åŸãããã«åã®ãã¡ã€ã«ãšäº€å·®ãããããšããŸãã
äžèšã®äŸã§ã¯ãæåã«config.jsonãã¡ã€ã«ããããã€ãã®æšæºèšå®ãååŸããsave.jsonãã¡ã€ã«ããä¿åãããèšå®ããããã«é©çšããŠãããç¹å®ã®æéã«é¢é£ããèšå®ãè¿œå ããŸãã åºåã§ã¯ã3ã€ã®JSONãªããžã§ã¯ããæ··åšããŠããŸãã ã¢ãžã¥ãŒã«ã«æž¡ãããåŒæ°ã®æ°ã¯ä»»æã§ãã ããšãã°ãããã©ã«ãèšå®ã®ã¿ãèŠæ±ã§ããŸãã
var data = config.get("config.json");
ãã³ã7. CEOåãã®ãã¡ã€ã«ãšãœãŒã·ã£ã«ãªã³ã¯ã¢ãžã¥ãŒã«ã®æäœ
NodeJSã§æ°ã«å ¥ã£ãŠããäž»ãªæ©èœã®1ã€ã¯ãJavaScriptã§ãã¡ã€ã«ãæäœããããŒãµãŒãäœæã§ããããšã§ãã åæã«ãNodeJS APIã¯åé¡ã解決ããããã®å€ãã®ã¡ãœãããšã¡ãœãããæäŸããŸãããå®éã«ã¯ããã»ã©å¿ èŠãããŸããã ããŒãµãŒã§ã®å幎éã®ã¢ã¯ãã£ããªäœæ¥ã§ã¯ããã¡ã€ã«ã®èªã¿åããšæžã蟌ã¿ã®2ã€ã®ã³ãã³ãã®ã¿ã䜿çšããŸããã ããã«ãã³ãŒã«ããã¯é¢æ°ãéåæã®ããŸããŸãªåé¡ã«æ©ãŸãããªãããã«ãç§ã¯åžžã«åæã¢ãŒãã§ãã¡ã€ã«ãæäœããŸããã ãã®ããããã¡ã€ã«ãæäœããããã®å°ããªã¢ãžã¥ãŒã«ãããããã®APIã¯localStorageã«éåžžã«äŒŒãŠããŸããã
var file = requery("./utils.file.js"), // text = file.get("text.txt); // file.set("text.txt", "Hello world!"); //
ãã¡ã€ã«ãæäœããããã®ãã®ã¢ãžã¥ãŒã«ã«åºã¥ããŠãä»ã®ã¢ãžã¥ãŒã«ã衚瀺ããå§ããŸããã ããšãã°ãCEOçšã®ã¢ãžã¥ãŒã«ã 以åã®èšäºã®1ã€ã§ãCEOã«é¢é£ããããŸããŸãªã¡ã¿ã¿ã°ãéåžžã«å€æ°ããããšãæ¢ã«æžããŸããã HTMLã¢ããªã±ãŒã·ã§ã³çšã®ã¢ã»ã³ããªã·ã¹ãã ã®èšè¿°ãéå§ãããšããCEOã«ç¹ã«æ³šæãæããŸããã
äžçªäžã®è¡ã¯ããµã€ã/ã¢ããªã±ãŒã·ã§ã³/ã²ãŒã ã®èª¬æãšè§£æçšã®HTMLãã¡ã€ã«èªäœãå«ãå°ããªããã¹ããã¡ã€ã«ãããããšã§ãã Social Linkã¢ãžã¥ãŒã«ã¯ãHTMLãã¡ã€ã«å ã§CEOã«é¢é£ãããã¹ãŠã®ã¡ã¿ã¿ã°ãèŠã€ããŠèšå ¥ããå¿ èŠããããŸãã å€éšã¢ãžã¥ãŒã«APIã¯ããã¡ã€ã«ããã®ããã¹ããå ¥åãšããŠäºæããŸãã ããã¯ãã¢ã»ã³ããªã·ã¹ãã ã«æ¥ç¶ããæ¯åäœåãªèªã¿åã/æžã蟌ã¿ãè¡ãããšãªããè€æ°ã®ãã¡ã€ã«ã®ããã¹ããå®è¡ã§ããããã«ããããã«è¡ãããŸãã
ããšãã°ãã¢ãžã¥ãŒã«ã®åã«ïŒ
<title></title> <meta property="og:title" content=""/> <meta name="twitter:title" content=""/>
ã¢ãžã¥ãŒã«ã®åŸïŒ
<title> </title> <meta property="og:title" content=" "/> <meta name="twitter:title" content=" "/>
CEOã®ãã¹ãŠã®ã¡ã¿ã¿ã°ã®ãªã¹ããšèª¬æã ãã§ãªããæ¬http://bakhirev.biz/ã§èŠãããšãã§ããŸãã
ãã³ã8.ã³ãŒã«ããã¯ããªããã°ã人çã¯æ¥œã«ãªããŸãã
å€ãã®éçºè ã¯ãNodeJSã§ãµãŒããŒãäœæãããšãã«ãã³ãŒã«ããã¯ã®ç¡éã®ãã§ãŒã³ã«ã€ããŠäžæºãèšã£ãŠããŸãã å®éãããªãã¯åžžã«ããããæžãããšã矩åä»ããããŠããããã§ã¯ãªãããã®ãããªãã§ãŒã³ãæå°éã«ãªããããªã¢ãŒããã¯ãã£ããã°ãã°æ§ç¯ããããšãã§ããŸãã å°ããªã¿ã¹ã¯ãæ€èšããŠãã ããããã£ã¬ã³ãžïŒ
ãµãŒããŒAãããµãŒããŒBã«ãã¡ã€ã«ã転éããããŒã¿ããŒã¹ããæ å ±ãååŸãããã®æ å ±ãæŽæ°ããŠããµãŒããŒBã«ããŒã¿ãéä¿¡ããŸãã
解決çïŒ
ããã¯ããœãŒã/åŠçã¿ã¹ã¯ã解決ããããã«ç¹°ãè¿ãå®è¡ããªããã°ãªããªãããªãæ¥åžžçãªæé ã§ãã éåžžãéçºè ã¯nextFileïŒïŒã¡ãœããã䜿çšããŠã«ãŒããšã³ãŒã«ããã¯é¢æ°ãäœæããŸãã 次ã®å埩ã§nextFileïŒïŒãåŒã³åºããšãã³ãŒã«ããã¯ã¡ã«ããºã ãæåããéå§ããã次ã®ãã¡ã€ã«ãåŠçããŸãã ååãšããŠãäžåºŠã«1ã€ã®ãã¡ã€ã«ã®ã¿ãåŠçããæé ãæ£åžžã«å®äºãããã次ã®ãã¡ã€ã«ã®åŠçã«é²ãå¿ èŠããããŸãã ãã¹ããç°¡åã«ããããã«ã次ã®ãã©ãŒã ã®ã³ãŒãã圹ç«ã¡ãŸãã
var locked = false, index = 0, timer = setInterval(function() { if(locked) return; locked = true; nextFile(index++); }, 1000);
ããã§ããã¡ã€ã«ã®åŠçã1ç§éã«éå§ããããšããŸãã ããã°ã©ã ã解æŸããããšãlockedãfalseã«èšå®ãããåŠçã®ããã«æ¬¡ã®ãã¡ã€ã«ãå®è¡ã§ããŸãã ãã®ãããªæ§é ã¯ããã¹ãã®åæžãæéã®çµéã«ããè² è·ã®åæ£ïŒæ¬¡ã®åŠçã®å埩ã1ç§ã«1åããéå§ãããªãããïŒãããã³ãšã³ãã¬ã¹ã³ãŒã«ããã¯ããå°ãªããšãå°ãã¯ããŒã«ããã®ã«åœ¹ç«ã¡ãŸãã
åèš
ã¢ãžã¥ãŒã«ãå«ããã¡ã€ã«ã¯ã http ïŒ //bakhirev.biz/_node.zipããããŠã³ããŒãã§ããŸãïŒçŸåšåå2æã§ãGitHubãåŠçããŠã³ãŒãã人éã®åœ¢ã«ããã®ãé¢åã§ãïŒã
æ¬ã¯ãã¡ãã§ãïŒ http : //bakhirev.biz/
ããã§PDFã®ãããå¹æã®å Žåã
äžèšã®ãã³ããæ°ã«å ¥ã£ãå Žåã¯ãããã«å¥ã®æ¬ã«é¢ããæ¬ã§ããããšãèŠåããããšæããŸãã ãããŠæåŸã«ããããçãããšãªãèªåèªèº«ã§ããããã®ãªãè²¢ç®ãããããŸããŸãªè³¢ã人ã ã®ãªã¹ãããããŸãã