{"id":302302,"date":"2020-04-22T09:01:03","date_gmt":"2020-04-22T09:01:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=302302"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2020-04-22T09:01:03","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=302302","title":{"rendered":"\u041c\u043e\u0449\u044c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u0432 JavaScript"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/498266\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/sg\/gw\/7f\/sggw7fgkvlubr0aoazpgb01rank.png\"><\/p>\n<p>  \u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p>  <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A0%D0%B5%D0%BA%D1%83%D1%80%D1%81%D0%B8%D1%8F\" rel=\"nofollow\">\u0420\u0435\u043a\u0443\u0440\u0441\u0438\u044f<\/a> \u2014 \u043e\u0434\u043d\u0430 \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0412\u044b\u0440\u0430\u0436\u0430\u044f\u0441\u044c \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u043e, \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f \u2014 \u044d\u0442\u043e \u043a\u043e\u0433\u0434\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u0430\u043c\u0430 \u0441\u0435\u0431\u044f.<\/p>\n<p>  \u041f\u0440\u043e\u0441\u0442\u044b\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0430\u043b\u0430 \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430:<\/p>\n<pre><code class=\"javascript\">function factorial(n) {   return (n != 1) ? n * factorial(n - 1) : 1; } <\/code><\/pre>\n<p>  \u0421\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u043e\u0432:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ad\/w5\/jz\/adw5jzcmvyorxkghiujl5c4jjws.gif\"><\/p>\n<p>  \u041f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438<\/h4>\n<p>  \u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430\u043c\u0438 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<ol>\n<li>\u041c\u0435\u043d\u044c\u0448\u0435 \u043a\u043e\u0434\u0430.<\/li>\n<li>\u041a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0447\u0438\u0449\u0435.<\/li>\n<li>\u041c\u0435\u043d\u044c\u0448\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u0438 \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043e\u043a.<\/li>\n<li>\u041c\u0435\u043d\u044c\u0448\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0437\u0430\u043f\u0443\u0441\u043a \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 (<a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%92%D1%80%D0%B5%D0%BC%D0%B5%D0%BD%D0%BD%D0%B0%D1%8F_%D1%81%D0%BB%D0%BE%D0%B6%D0%BD%D0%BE%D1%81%D1%82%D1%8C_%D0%B0%D0%BB%D0%B3%D0%BE%D1%80%D0%B8%D1%82%D0%BC%D0%B0\" rel=\"nofollow\">\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430<\/a>).<\/li>\n<li>\u041b\u0435\u0433\u0447\u0435 \u0440\u0435\u0448\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u044b\u043c\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/li>\n<li>\u041b\u0435\u0433\u0447\u0435 <a href=\"https:\/\/algorithm-visualizer.org\/\" rel=\"nofollow\">\u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b<\/a>.<\/li>\n<\/ol>\n<p>  <\/p>\n<h4>\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438<\/h4>\n<p>  \u041a \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0430\u043c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043d\u0435\u0441\u0442\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<ol>\n<li>\u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e\u0439.<\/li>\n<li>\u041c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u0441\u0442\u0435\u043a\u0430 \u0432\u044b\u0437\u043e\u0432\u043e\u0432.<\/li>\n<li>\u041f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u043e\u0431\u044a\u0435\u043c \u043f\u0430\u043c\u044f\u0442\u0438, \u0447\u0435\u043c \u0446\u0438\u043a\u043b (\u0435\u0441\u043b\u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A5%D0%B2%D0%BE%D1%81%D1%82%D0%BE%D0%B2%D0%B0%D1%8F_%D1%80%D0%B5%D0%BA%D1%83%D1%80%D1%81%D0%B8%D1%8F\" rel=\"nofollow\">\u0445\u0432\u043e\u0441\u0442\u043e\u0432\u043e\u0439 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438<\/a>).<\/li>\n<\/ol>\n<p>  <\/p>\n<h3>\u0417\u0430\u0447\u0435\u043c \u043d\u0430\u043c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f?<\/h3>\n<p>  \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043b\u044e\u0431\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0446\u0438\u043a\u043b\u0430. \u0428\u0442\u0443\u043a\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0437\u043d\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044e \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043b\u0443\u0447\u0448\u0438\u043c \u0432\u044b\u0431\u043e\u0440\u043e\u043c \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0446\u0438\u043a\u043b\u043e\u043c.<\/p>\n<p>  \u0418 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430 \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0432\u0441\u044e \u043c\u043e\u0449\u044c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0440\u043e <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A5%D0%B0%D0%BD%D0%BE%D0%B9%D1%81%D0%BA%D0%B0%D1%8F_%D0%B1%D0%B0%D1%88%D0%BD%D1%8F\" rel=\"nofollow\">\u0425\u0430\u043d\u043e\u0439\u0441\u043a\u0443\u044e \u0431\u0430\u0448\u043d\u044e<\/a>).<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440\u044b<\/h3>\n<p>  \u041b\u0443\u0447\u0448\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u043d\u044f\u0442\u044c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044e \u2014 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u0430\u0440\u043e\u0447\u043a\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432.<\/p>\n<h4>\u041f\u0435\u0440\u0435\u0431\u043e\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (\u043f\u0440\u043e\u0445\u043e\u0434 \u043f\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c, \u0442\u0440\u0430\u0432\u0435\u0440\u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432)<\/h4>\n<p>  \u041a\u0430\u043a \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b\u043e\u0441\u044c \u0440\u0430\u043d\u0435\u0435, \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u044b\u043c\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u0413\u043b\u0443\u0431\u043e\u043a\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442 \u2014 \u044d\u0442\u043e, \u043f\u043e \u0441\u0443\u0442\u0438, \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 HTML DOM. \u0414\u0430\u043d\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u043c\u0435\u0435\u0442 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b. \u041a\u0430\u0436\u0434\u044b\u0439 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043a\u0430\u0436\u0434\u044b\u0439 \u00ab\u0440\u0435\u0431\u0435\u043d\u043e\u043a\u00bb \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c HTML DOM \u0438 \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u00ab\u0434\u0435\u0442\u0435\u0439\u00bb, \u0442\u0430\u043a \u0447\u0442\u043e \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u0442\u043e\u043c\u043a\u043e\u0432 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e-\u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u043c\u0443 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442.<\/p>\n<p>  \u041d\u0430\u0448\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u00ab\u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438\u00bb.<\/p>\n<p>  \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043a\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u00abstyle\u00bb (\u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430) \u0438 \u043c\u0435\u043d\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u00abborder\u00bb, \u00abtextColor\u00bb \u0438 \u00abwidth\u00bb \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 JavaScript.<\/p>\n<p>  \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u0442\u0438\u043b\u0435\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c:<\/p>\n<pre><code class=\"javascript\">{     &quot;border&quot;: {         &quot;color&quot;: &quot;hotpink&quot;,         &quot;width&quot;: &quot;2px&quot;     },     &quot;textColor&quot;: &quot;paleviolet&quot;,     &quot;width&quot;: &quot;0.45&quot; } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0446\u0432\u0435\u0442\u0430 \u0442\u0435\u043a\u0441\u0442\u0430 \u0432 HTML \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u00abcolor\u00bb, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 textColor \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u043e \u0432 color.<\/p>\n<p>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 width \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u044b \u043e\u0442 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 (\u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u043e \u0432 45vw), \u0430 border \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u043e \u0432 { borderColor: &#8216;hotpink&#8217;, borderWidth: &#8216;2px&#8217; }.<\/p>\n<p>  \u041d\u0430\u0448 \u00ab\u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u044b\u0439\u00bb \u043e\u0431\u044a\u0435\u043a\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"javascript\">{     &quot;type&quot;: &quot;div&quot;,     &quot;style&quot;: {},     &quot;children&quot;: [{         &quot;type&quot;: &quot;div&quot;,         &quot;style&quot;: {             &quot;backgroundColor&quot;: &quot;black&quot;,             &quot;border&quot;: {                 &quot;color&quot;: &quot;hotpink&quot;,                 &quot;width&quot;: &quot;2px&quot;,                 &quot;style&quot;: &quot;dashed&quot;             },             &quot;fontStyle&quot;: &quot;italic&quot;,             &quot;padding&quot;: &quot;20px 25px&quot;,             &quot;textColor&quot;: &quot;white&quot;         },         &quot;children&quot;: [{                 &quot;type&quot;: &quot;button&quot;,                 &quot;style&quot;: {                     &quot;backgroundColor&quot;: &quot;#fda512&quot;,                     &quot;border&quot;: {                         &quot;color&quot;: &quot;red&quot;                     },                     &quot;textColor&quot;: &quot;#fff&quot;                 }             },             {                 &quot;type&quot;: &quot;label&quot;,                 &quot;style&quot;: {                     &quot;height&quot;: &quot;0.04&quot;,                     &quot;width&quot;: &quot;0.04&quot;                 },                 &quot;children&quot;: [{                     &quot;type&quot;: &quot;label&quot;,                     &quot;style&quot;: {                         &quot;border&quot;: {                             &quot;style&quot;: &quot;solid&quot;,                             &quot;width&quot;: &quot;5px&quot;                         },                         &quot;fontStyle&quot;: &quot;italic&quot;                     },                     &quot;children&quot;: [{                         &quot;type&quot;: &quot;span&quot;,                         &quot;style&quot;: {                             &quot;backgroundColor&quot;: &quot;#039392&quot;,                             &quot;borderRadius&quot;: &quot;10px&quot;,                             &quot;height&quot;: &quot;0.03&quot;,                             &quot;outline&quot;: &quot;none&quot;,                             &quot;width&quot;: &quot;0.783&quot;                         }                     }]                 }]             }         ]     }] } <\/code><\/pre>\n<p>  \u0418\u0442\u0430\u043a, \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u0433\u0434\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u00abchildren\u00bb.<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u00abtransformStyleObject\u00bb, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0443\u044e \u0441\u0442\u0438\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0443\u044e \u0438\u0445 \u2014 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0443\u044e \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 JS \u0438 DOM:<\/p>\n<pre><code class=\"javascript\">function transformStyleObject(styleObj) {     const result = {}     const keys = Object.keys(styleObj)      keys.forEach(key =&gt; {         if (key === 'border') {             const {                 color,                 width,                 style             } = styleObj.border             if (color) result.borderColor = color             if (width) result.borderWidth = width             if (style) result.borderStyle = style         } else if (key === 'textColor') {             result['color'] = styleObj.textColor         } else if (key === 'width') {             result['width'] = `${Number(styleObj.width) * 100}vw`         } else if (key === 'height') {             result['height'] = `${Number(styleObj.height) * 100}vh`         } else {             result[key] = styleObj[key]         }     })     return result }  const result = transformStyleObject({     border: {         width: '2px',         style: 'dashed',     },     height: '0.42', })  console.log(result) \/\/ result: { borderWidth: '2px', borderStyle: 'dashed', height: '42vh'} <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043f\u0440\u043e\u0445\u043e\u0434\u0430 \u043f\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0446\u0438\u043a\u043b:<\/p>\n<pre><code class=\"javascript\">function transformAll({     type = '',     style = {},     children = [] }) {     const result = {         type,         style: transformStyleObject(style),         children     }      if (Array.isArray(result.children)) {         for (let i = 0; i &lt; result.children.length; i++) {             const child = result.children[i]             child.style = transformStyleObject(child.style)              if (Array.isArray(child.children)) {                 for (let i = 0; i &lt; child.children.length; i++) {                     const childsChild = child.children[i]                     childsChild.style = transformStyleObject(childsChild.style)                      if (Array.isArray(childsChildren.children)) {                         for (let i = 0; i &lt; childsChildren.children.length; i++) {                             const childsChildsChild = childsChild.children[i]                             \/\/ \u0438 \u0442.\u0434.                         }                     }                 }             }         }     }     return result } <\/code><\/pre>\n<p>  \u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b \u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u0442 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c:<\/p>\n<ol>\n<li>\u041a\u043e\u0434 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0434\u043b\u0438\u043d\u043d\u044b\u043c<\/li>\n<li>\u0415\u0433\u043e \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0442\u0440\u0443\u0434\u043d\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c<\/li>\n<li>\u041e\u043d \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043a \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c<\/li>\n<li>\u0415\u0433\u043e \u0442\u0440\u0443\u0434\u043d\u0435\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c<\/li>\n<li>\u041c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u043f\u0443\u0442\u0430\u043d\u0438\u0446\u0430 \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438<\/li>\n<\/ol>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044e \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c:<\/p>\n<pre><code class=\"javascript\">function transformAll({     type = '',     style = {},     children = [] }) {     const result = {         type,         style: transformStyleObject(style),         children     }     if (Array.isArray(result.children)) {         result.children = result.children.map(transformAll)     }     return result } <\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"javascript\">{     &quot;type&quot;: &quot;div&quot;,     &quot;style&quot;: {},     &quot;children&quot;: [{         &quot;type&quot;: &quot;div&quot;,         &quot;style&quot;: {             &quot;backgroundColor&quot;: &quot;black&quot;,             &quot;borderColor&quot;: &quot;hotpink&quot;,             &quot;borderWidth&quot;: &quot;2px&quot;,             &quot;borderStyle&quot;: &quot;dashed&quot;,             &quot;fontStyle&quot;: &quot;italic&quot;,             &quot;padding&quot;: &quot;20px 25px&quot;,             &quot;color&quot;: &quot;white&quot;         },         &quot;children&quot;: [{                 &quot;type&quot;: &quot;button&quot;,                 &quot;style&quot;: {                     &quot;backgroundColor&quot;: &quot;#fda512&quot;,                     &quot;borderColor&quot;: &quot;red&quot;,                     &quot;color&quot;: &quot;#ffffff&quot;                 },                 &quot;children&quot;: []             },             {                 &quot;type&quot;: &quot;label&quot;,                 &quot;style&quot;: {                     &quot;height&quot;: &quot;4vh&quot;,                     &quot;width&quot;: &quot;4vw&quot;                 },                 &quot;children&quot;: [{                     &quot;type&quot;: &quot;label&quot;,                     &quot;style&quot;: {                         &quot;borderWidth&quot;: &quot;5px&quot;,                         &quot;borderStyle&quot;: &quot;solid&quot;,                         &quot;fontStyle&quot;: &quot;italic&quot;                     },                     &quot;children&quot;: [{                         &quot;type&quot;: &quot;span&quot;,                         &quot;style&quot;: {                             &quot;backgroundColor&quot;: &quot;#039392&quot;,                             &quot;borderRadius&quot;: &quot;10px&quot;,                             &quot;height&quot;: &quot;3vh&quot;,                             &quot;outline&quot;: &quot;none&quot;,                             &quot;width&quot;: &quot;78.3vw&quot;                         },                         &quot;children&quot;: []                     }]                 }]             }         ]     }] } <\/code><\/pre>\n<p>  \u0421\u043e\u0433\u043b\u0430\u0441\u0438\u0442\u0435\u0441\u044c, \u0442\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043b\u0443\u0447\u0448\u0435! \u0412\u043e\u0442 \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u044d\u0442\u0430 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f:<\/p>\n<ol>\n<li>transformAll \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 HTML DOM \u044d\u043b\u0435\u043c\u0435\u043d\u0442<\/li>\n<li>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0441\u0442\u0438\u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430<\/li>\n<li>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0438\u043c\u0435\u044e\u0442\u0441\u044f \u043b\u0438 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043f\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 \u00abchildren\u00bb<\/li>\n<li>\u0415\u0441\u043b\u0438 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438\u043c\u0435\u044e\u0442\u0441\u044f, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u00abtransformStyleObject\u00bb \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445<\/li>\n<li>\u0420\u0435\u043a\u0443\u0440\u0441\u0438\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0443\u0440\u043e\u0432\u043d\u044f \u0435\u0433\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438<\/li>\n<\/ol>\n<p>  <\/p>\n<h3>\u0420\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0438 \u043f\u0430\u043f\u043a\u0430\u043c\u0438<\/h3>\n<p>  \u041b\u0438\u0447\u043d\u043e \u044f \u043b\u044e\u0431\u043b\u044e \u043f\u0438\u0441\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434. \u0418 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442.<\/p>\n<p>  \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043a\u0430\u0436\u0434\u0443\u044e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0441 \u0438\u043c\u0435\u043d\u0435\u043c &quot;__test__&quot; \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0435 \u0431\u044b\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b (\u043f\u043e \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044e \u0438\u043c\u0435\u043d\u0438 \u043d\u0430 &quot;.test.js&quot;).<\/p>\n<p>  \u041a\u0430\u0436\u0434\u0430\u044f \u043f\u0430\u043f\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u00ab\u043c\u043e\u0434\u0443\u043b\u0435\u043c\u00bb. \u0415\u0441\u043b\u0438 \u0432 \u043d\u0435\u0439 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f \u0441 \u0438\u043c\u0435\u043d\u0435\u043c &quot;__test__&quot; \u0438\u043b\u0438 \u0444\u0430\u0439\u043b, \u0438\u043c\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 &quot;.test.js&quot;, \u0437\u043d\u0430\u0447\u0438\u0442, \u043e\u043d \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<p>  \u041f\u0440\u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0438 \u0442\u0435\u0441\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"javascript\">{     &quot;..\/javascript-algorithms\/src\/algorithms\/math\/linked-list&quot;: {         &quot;name&quot;: &quot;linked-list&quot;,         &quot;category&quot;: &quot;algorithms&quot;,         &quot;subcategory&quot;: &quot;math&quot;,         &quot;totalFiles&quot;: 0,         &quot;filesList&quot;: []     } } <\/code><\/pre>\n<p>  \u041a\u043e\u043d\u0435\u0447\u043d\u044b\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0442\u0430\u043a\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0433\u0434\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043f\u0430\u043f\u043a\u0443, \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0443\u044e \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f.<\/p>\n<p>  \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u044d\u0442\u043e\u0442 <a href=\"https:\/\/github.com\/trekhleb\/javascript-algorithms\" rel=\"nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441 JS-\u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c\u0438<\/a>. \u0421\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0435\u0433\u043e. \u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0443 \u00absrc\u00bb \u0438 \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0438\u0437 \u043f\u0430\u0440\u043e\u0447\u043a\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b.<\/p>\n<p>  \u0414\u043b\u044f \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c Node.js.<\/p>\n<p>  \u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c fs \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043a\u043e\u0440\u043d\u0435\u0432\u0443\u044e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e:<\/p>\n<pre><code class=\"javascript\">import fs from 'fs'  const rootDir = '..\/javascript-algorithms\/src' <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u044b \u0437\u0430\u0448\u043b\u0438 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u043c isDirectory \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u044f fs. \u042f \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044e \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u043c\u0435\u0442\u043e\u0434:<\/p>\n<pre><code class=\"javascript\">function isDirectory(filepath) {     return fs.statSync(filepath).isDirectory() } <\/code><\/pre>\n<p>  C\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u00abhasTest\u00bb, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0443\u044e \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u0442\u0440\u043e\u043a, \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0449\u0443\u044e \u043f\u043e \u043d\u0435\u043c\u0443 \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0443\u044e \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0442\u0435\u0441\u0442\u043e\u0432. \u041f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0442\u0435\u0441\u0442\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f true, \u0438\u043d\u0430\u0447\u0435 \u2014 false:<\/p>\n<pre><code class=\"javascript\">function hasTest(testDir) {     for (let i = 0; i &lt; testDir.length; i++) {         const filename = testDir[i]         if (filename.endsWith('.test.js')) {             return true         }     }     return false } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0433\u043b\u0430\u0432\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u00abfindEmptyTests\u00bb, \u0430\u043a\u043a\u0443\u043c\u0443\u043b\u0438\u0440\u0443\u044e\u0449\u0443\u044e \u043c\u043e\u0434\u0443\u043b\u0438 \u0431\u0435\u0437 \u0442\u0435\u0441\u0442\u043e\u0432:<\/p>\n<pre><code class=\"javascript\">function findEmptyTests(basepath) {     let emptyTests = {}      if (isDirectory(basepath)) {         const dir = fs.readdirSync(basepath)          for (let i = 0; i &lt; dir.length; i++) {             const filename = dir[i]             const filepath = `${basepath}\/${filename}`              if (isDirectory(filepath)) {                 if (filename === '__test__') {                     const testDir = fs.readdirSync(filepath)                     if (!hasTest(testDir)) {                         emptyTests[filepath] = createMissingTestsObject(basepath, testDir)                     }                 } else {                     emptyTests = {                         ...emptyTests,                         ...findEmptyTests(filepath)                     }                 }             }         }     }     return emptyTests } <\/code><\/pre>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0435 \u043c\u044b \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c, \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u0430\u043c\u0430 \u0441\u0435\u0431\u044f:<\/p>\n<pre><code class=\"javascript\">emptyTests = {     ...emptyTests,     ...findEmptyTests(filepath) } <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0441\u0430\u043c\u0430\u044f \u0432\u0430\u0436\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c!<\/p>\n<p>  \u041c\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u00abfindEmptyTests\u00bb \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 (\u043f\u0443\u0442\u044c \u0444\u0430\u0439\u043b\u0430).<\/p>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0438\u0445 \u0438\u043c\u0435\u043d\u0430 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u00abdir\u00bb.<\/p>\n<p>  \u0417\u0430\u0442\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0446\u0438\u043a\u043b, \u0432 \u0445\u043e\u0434\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<ol>\n<li>\u0415\u0441\u043b\u0438 \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f &quot;__test__&quot;, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432, \u0438\u043c\u0435\u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0430 &quot;.test.js&quot;. \u0415\u0441\u043b\u0438 \u0442\u0430\u043a\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0435\u0442, \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043c\u043e\u0434\u0443\u043b\u0435 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043e\u0431\u044a\u0435\u043a\u0442 \u00abemptyTests\u00bb.<\/li>\n<li>\u0415\u0441\u043b\u0438 \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f \u043d\u0435 __test__, \u0437\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u043d\u0435\u0435 \u0438 \u0441\u043d\u043e\u0432\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u0442.\u0434.<\/li>\n<\/ol>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.<\/p>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u00abcreateMissingTestsObject\u00bb \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u0443\u0442\u0438 \u0438 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438:<\/p>\n<pre><code class=\"javascript\">function createMissingTestsObject(str, dir) {     const indexToSrc = str.indexOf('src')     let category = str.substring(indexToSrc + 4)     let subcategory = category.substring(category.indexOf('\/') + 1)     subcategory = subcategory.substring(0, subcategory.indexOf('\/'))     category = category.substring(0, category.indexOf('\/'))      return {         name: str.substring(str.lastIndexOf('\/') + 1),         category,         subcategory,         totalFiles: dir.length,         filesList: dir     } } <\/code><\/pre>\n<p>  \u041d\u0430\u0448\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f \u2014 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f\u043c\u0438 \u0431\u0435\u0437 \u0442\u0435\u0441\u0442\u043e\u0432!<\/p>\n<pre><code class=\"javascript\">{     &quot;..\/javascript-algorithms\/src\/algorithms\/math\/fourier-transform\/__test__&quot;: {         &quot;name&quot;: &quot;fourier-transform&quot;,         &quot;category&quot;: &quot;algorithms&quot;,         &quot;subcategory&quot;: &quot;math&quot;,         &quot;totalFiles&quot;: 1,         &quot;filesList&quot;: [&quot;FourierTester.js&quot;]     },     &quot;..\/javascript-algorithms\/src\/algorithms\/sets\/cartesian-product\/__test__&quot;: {         &quot;name&quot;: &quot;cartesian-product&quot;,         &quot;category&quot;: &quot;algorithms&quot;,         &quot;subcategory&quot;: &quot;sets&quot;,         &quot;totalFiles&quot;: 0,         &quot;filesList&quot;: []     },     &quot;..\/javascript-algorithms\/src\/algorithms\/sets\/combination-sum\/__test__&quot;: {         &quot;name&quot;: &quot;combination-sum&quot;,         &quot;category&quot;: &quot;algorithms&quot;,         &quot;subcategory&quot;: &quot;sets&quot;,         &quot;totalFiles&quot;: 0,         &quot;filesList&quot;: []     } } <\/code><\/pre>\n<p>  \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u044b \u043d\u0430\u0448\u043b\u0438 \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0435.<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/498266\/\"> https:\/\/habr.com\/ru\/post\/498266\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/498266\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/sg\/gw\/7f\/sggw7fgkvlubr0aoazpgb01rank.png\"><\/p>\n<p>  \u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p>  <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A0%D0%B5%D0%BA%D1%83%D1%80%D1%81%D0%B8%D1%8F\" rel=\"nofollow\">\u0420\u0435\u043a\u0443\u0440\u0441\u0438\u044f<\/a> \u2014 \u043e\u0434\u043d\u0430 \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0412\u044b\u0440\u0430\u0436\u0430\u044f\u0441\u044c \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u043e, \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f \u2014 \u044d\u0442\u043e \u043a\u043e\u0433\u0434\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u0430\u043c\u0430 \u0441\u0435\u0431\u044f.<\/p>\n<p>  \u041f\u0440\u043e\u0441\u0442\u044b\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0430\u043b\u0430 \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430:<\/p>\n<pre><code class=\"javascript\">function factorial(n) {   return (n != 1) ? n * factorial(n - 1) : 1; } <\/code><\/pre>\n<p>  \u0421\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u043e\u0432:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ad\/w5\/jz\/adw5jzcmvyorxkghiujl5c4jjws.gif\"><\/p>\n<p>  \u041f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-302302","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/302302","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=302302"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/302302\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=302302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=302302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=302302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}