{"id":315638,"date":"2020-12-28T03:00:31","date_gmt":"2020-12-28T03:00:31","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=315638"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=315638","title":{"rendered":"\u0421\u0442\u0440\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\n<p>\u0412\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u044b \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0434\u0438 \u0437\u0430\u0431\u0430\u0432\u044b \u0437\u0430\u0431\u0443\u0434\u0435\u043c \u043e\u0431 \u044d\u0442\u043e\u043c. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u0430 \u043f\u0440\u043e\u0439\u0434\u0451\u043c\u0441\u044f \u043f\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0421\u0443\u043c\u0430\u0441\u0448\u0435\u0441\u0442\u0432\u0438\u0435, \u0441\u043a\u0430\u0436\u0435\u0442\u0435 \u0432\u044b!<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/de\/76\/ib\/de76ibuom2m5hxpkrrzn_bpdqgm.png\" alt=\"image Nordic YES\"><\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h2 id=\"po-chyom-bezhat-budem\">\u041f\u043e \u0447\u0451\u043c \u0431\u0435\u0436\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u043c?<\/h2>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0431\u0435\u0436\u0430\u0442\u044c \u043f\u043e \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043d\u043e\u0439 \u043a\u043d\u0438\u0433\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const phoneBook = {   andrew: [&quot;+345356245254&quot;, &quot;+313232312312&quot;],   vasilina: [&quot;+132313123123&quot;],   serhiy: [&quot;+587234878234&quot;, &quot;+321323124123&quot;], };<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"chto-hotim-poluchit\">\u0427\u0442\u043e \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c?<\/h2>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u043d\u043e\u043c\u0435\u0440\u043e\u0432.<\/p>\n<p>  <\/p>\n<h2 id=\"kak-my-eto-sdelaem\">\u041a\u0430\u043a \u043c\u044b \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u043c?<\/h2>\n<p>  <\/p>\n<p>\u041c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u0432 4 \u0448\u0430\u0433\u0430:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0434\u043b\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445<\/li>\n<li>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u0431\u044b\u0447\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438<\/li>\n<li>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u043e\u0431\u043e\u0447\u043d\u044b\u0439 \u044d\u0444\u0444\u0435\u043a\u0442 \u0441\u043e\u0431\u0438\u0440\u0430\u043d\u0438\u044f \u043d\u043e\u043c\u0435\u0440\u043e\u0432 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432<\/li>\n<li>\u041e\u0431\u0435\u0440\u043d\u0451\u043c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0411\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 <a href=\"https:\/\/www.npmjs.com\/package\/quartet\" rel=\"nofollow\"><code>quartet<\/code><\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">import { v } from &quot;quartet&quot;;<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const checkPhoneBook = v({   [v.rest]: v.arrayOf(v.string), });<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043d\u0435\u043a\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043d\u043e\u0439 \u043a\u043d\u0438\u0433\u043e\u0439:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">checkPhoneBook({}); \/\/ true checkPhoneBook({ andrew: [&quot;123321&quot;] }); \/\/ true checkPhoneBook({ andrew: null }); \/\/ false<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u0443\u043c\u0430\u0441\u0448\u0435\u0441\u0442\u0432\u0438\u044f: \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u043f\u0438\u0441\u043a\u0430 \u043d\u043e\u043c\u0435\u0440\u043e\u0432 \u0431\u0443\u0434\u0435\u043c \u0435\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u043c\u0430\u0441\u0441\u0438\u0432.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const phoneNumbers = []; const checkAndCollect = v({   [v.rest]: v.arrayOf(     v.and(       v.string,       v.custom((phoneNumber) =&gt; {         phoneNumbers.push(phoneNumber);         return true;       })     )   ), });<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u044b\u0437\u043e\u0432\u0435\u043c \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043d\u043e\u0439 \u043a\u043d\u0438\u0433\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">checkAndCollect({   andrew: [&quot;+345356245254&quot;, &quot;+313232312312&quot;],   vasilina: [&quot;+132313123123&quot;],   serhiy: [&quot;+587234878234&quot;, &quot;+321323124123&quot;], });<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u0435\u0440\u043d\u0443\u043b\u043e\u0441\u044c <code>true<\/code>. \u041d\u043e \u043d\u0430\u0441 \u044d\u0442\u043e \u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442! \u0413\u043b\u0430\u0432\u043d\u043e\u0435: \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 <code>phoneNumbers<\/code> \u0442\u0435\u043f\u0435\u0440\u044c \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432\u0441\u0435 \u043d\u043e\u043c\u0435\u0440\u0430.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">console.log(phoneNumbers); \/\/ [ \/\/   '+345356245254', \/\/   '+313232312312', \/\/   '+132313123123', \/\/   '+587234878234', \/\/   '+321323124123' \/\/ ]<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0431\u0435\u0440\u043d\u0451\u043c \u044d\u0442\u043e \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u00ab\u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f\u00bb:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">import { v } from &quot;quartet&quot;;  \/**  * @param {Record&lt;string, string[]&gt;} phoneBook  * @returns {string[]} phone numbers  *\/ function collectPhoneNumbers(phoneBook) {   const phoneNumbers = [];    const checkAndCollect = v({     [v.rest]: v.arrayOf(       v.and(         v.string,         v.custom((phoneNumber) =&gt; {           phoneNumbers.push(phoneNumber);           return true;         })       )     ),   });    checkAndCollect(phoneBook);    return phoneNumbers; }<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"ocenka\">\u041e\u0446\u0435\u043d\u043a\u0430<\/h2>\n<p>  <\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u043a\u0438\u0445 \u0442\u0440\u044e\u043a\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u0431\u0430\u0432\u043d\u044b\u043c. \u041d\u043e \u044f \u0431\u044b \u043d\u0435 \u043f\u0438\u0441\u0430\u043b \u0442\u0430\u043a \u0432 production \u043a\u043e\u0434\u0435. \u0418 \u043f\u043e \u0447\u0435\u0442\u044b\u0440\u0435\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u042d\u0442\u043e \u043d\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e \u043a\u043d\u0438\u0433\u0435 \u043d\u043e\u043c\u0435\u0440\u043e\u0432 \u2014 \u043b\u0438\u0448\u043d\u0435\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435.<\/li>\n<li>\u042d\u0442\u043e \u043d\u0435 \u0438\u0434\u0438\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043e\u0434. \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u043d\u0435 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u0434\u043b\u044f \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439.<\/li>\n<li>\u042d\u0442\u043e \u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u043a\u043e\u0434. \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0438 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u043c \u0432\u044b\u0437\u043e\u0432\u0430\u043c \u043a\u0430\u0440\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u0430.<\/li>\n<li>\u0415\u0441\u0442\u044c \u043a\u043e\u0434 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438:<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/**  * @param {Record&lt;string, string[]&gt;} phoneBook  * @returns {string[]} phone numbers  *\/ function collectPhoneNumbers(phoneBook) {   const phoneNumbers = [];    const personNames = Object.keys(phoneBook);    for (const personName of personNames) {     const personPhoneNumbers = phoneBook[personName];     phoneNumbers.push(...personPhoneNumbers);   }    return phoneNumbers; }<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"posleslovie\">\u041f\u043e\u0441\u043b\u0435\u0441\u043b\u043e\u0432\u0438\u0435<\/h2>\n<p>  <\/p>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a\u0443\u044e \u0437\u0430\u0431\u0430\u0432\u0443 \u044f \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b \u0432 \u0412\u043e\u0441\u043a\u0440\u0435\u0441\u0435\u043d\u0438\u0435 \u0432\u0435\u0447\u0435\u0440\u043e\u043c. \u0410 \u0447\u0442\u043e \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0432 \u0432\u0430\u0448\u0443 \u0433\u043e\u043b\u043e\u0432\u0443? \u041d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0445.<\/p>\n<\/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\/535258\/\"> https:\/\/habr.com\/ru\/post\/535258\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\n<p>\u0412\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u044b \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0434\u0438 \u0437\u0430\u0431\u0430\u0432\u044b \u0437\u0430\u0431\u0443\u0434\u0435\u043c \u043e\u0431 \u044d\u0442\u043e\u043c. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u0430 \u043f\u0440\u043e\u0439\u0434\u0451\u043c\u0441\u044f \u043f\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0421\u0443\u043c\u0430\u0441\u0448\u0435\u0441\u0442\u0432\u0438\u0435, \u0441\u043a\u0430\u0436\u0435\u0442\u0435 \u0432\u044b!<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/de\/76\/ib\/de76ibuom2m5hxpkrrzn_bpdqgm.png\" alt=\"image Nordic YES\"><\/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-315638","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/315638","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=315638"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/315638\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=315638"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=315638"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=315638"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}