{"id":305780,"date":"2020-06-23T09:00:55","date_gmt":"2020-06-23T09:00:55","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=305780"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=305780","title":{"rendered":"Todo-\u043b\u0438\u0441\u0442 \u0434\u043b\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043d\u0430 Deno"},"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\/company\/funcorp\/blog\/507282\/\">\n<p>\u0412\u044b \u0443\u0436\u0435 \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0441\u043b\u044b\u0448\u0430\u043b\u0438 \u043f\u0440\u043e Deno \u0438, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043b\u0438 \u043f\u0430\u0440\u0443-\u0442\u0440\u043e\u0439\u043a\u0443 \u043e\u0431\u0437\u043e\u0440\u043e\u0432. \u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0441\u0432\u043e\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0438\u0441\u043f\u044b\u0442\u0430\u0442\u044c Deno \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435, \u043d\u0430\u043f\u0438\u0441\u0430\u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u043f\u043e\u043f\u0443\u0442\u043d\u043e \u0440\u0430\u0437\u043c\u044b\u0448\u043b\u044f\u044f \u043e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430\u0445 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u0445 \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u0432\u043e\u0434\u043e\u043c \u0438 \u0432\u044b\u0432\u043e\u0434\u043e\u043c \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ng\/px\/c6\/ngpxc6lniysqyciixbblngga_vk.jpeg\"><\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c, TypeScript \u00ab\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438\u00bb, \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b, \u043e\u0431\u0448\u0438\u0440\u043d\u0430\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u043f\u043e URL, \u0432\u044b\u0433\u043e\u0434\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442 Deno \u043e\u0442 Node \u0438 Bash. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Deno \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442, \u0437\u0430\u043b\u0438\u0442\u044c \u043d\u0430 GitHub Gist \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>deno run https:\/\/path.to\/script.ts<\/code>, \u043d\u0435 \u0437\u0430\u0431\u043e\u0442\u044f\u0441\u044c \u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u0445 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0443\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c Deno \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 <a href=\"https:\/\/deno.land\/#installation\">https:\/\/deno.land\/#installation<\/a>.<\/p>\n<p>  <\/p>\n<h2 id=\"todo-dlya-todo\">Todo \u0434\u043b\u044f Todo<\/h2>\n<p>  <\/p>\n<p>Todo-\u043b\u0438\u0441\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0443\u043c\u0435\u0442\u044c:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c, \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0438 \u043e\u0442\u043c\u0435\u0447\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438;<\/li>\n<li>\u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u0434\u0430\u0447;<\/li>\n<li>\u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435;<\/li>\n<li>\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435;<\/li>\n<li>\u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440.<\/li>\n<\/ul>\n<p>  <\/p>\n<h2 id=\"argumenty-komandnoy-stroki\">\u0410\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438<\/h2>\n<p>  <\/p>\n<p>\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043b\u044e\u0431\u0430\u044f \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u0430\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u0412 Deno \u043e\u043d\u0438 \u043b\u0435\u0436\u0430\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u0432 <code>Deno.args<\/code>. \u0410, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0432 Node \u043c\u044b \u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 <code>process.argv<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u043e\u043c\u0438\u043c\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u0438 <code>node<\/code> \u0438 <code>\u043f\u0443\u0442\u044c \u043a \u0441\u043a\u0440\u0438\u043f\u0442\u0443<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ deno run args.ts first second  console.log(Deno.args) \/\/ [ &quot;first&quot;, &quot;second&quot; ]<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 <code>Deno.args<\/code> \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0430 \u0432 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0430\u0440\u0441\u0435\u0440\u043e\u043c \u0438\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438: <a href=\"https:\/\/deno.land\/std\/flags\">https:\/\/deno.land\/std\/flags<\/a> \u0438\u043b\u0438 \u043b\u044e\u0431\u044b\u043c \u0434\u0440\u0443\u0433\u0438\u043c \u043d\u0430 \u0432\u044b\u0431\u043e\u0440.<\/p>\n<p>  <\/p>\n<h2 id=\"itak-nachnyom\">\u0418\u0442\u0430\u043a, \u043d\u0430\u0447\u043d\u0451\u043c\u2026<\/h2>\n<p>  <\/p>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u0435\u0440\u0432\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u2013 \u0432\u044b\u0432\u043e\u0434 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438.<\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u2013 <code>todo.ts<\/code>. \u041b\u0443\u0447\u0448\u0435 \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u043e\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043e\u043d \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043d\u0430\u043c \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <code>\/src\/ui.ts<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u00ab\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u00bb. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443 <code>help<\/code>, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">export const help = `todo help - to show available commands`;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 <code>todo.ts<\/code> \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u0432\u0438\u0442\u0447 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u043e\u043c\u0430\u043d\u0434 \u0438 \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u0441\u043f\u0440\u0430\u0432\u043a\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>console.log()<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">#!\/usr\/bin\/env deno run  import { help } from &quot;.\/src\/ui.ts&quot;;  const [command, ...args] = Deno.args;  switch (command) {   case &quot;help&quot;:     console.log(help); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<p>  <\/p>\n<p><code>deno run todo.ts help<\/code><\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043d\u0435 \u043f\u0438\u0441\u0430\u0442\u044c deno run, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0448\u0435\u0431\u0430\u043d\u0433 <code>#!<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">#!\/usr\/bin\/env deno run<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u0440\u0435\u0448\u0438\u043c \u0437\u0430\u043f\u0443\u0441\u043a \u0444\u0430\u0439\u043b\u0430:<\/p>\n<p>  <\/p>\n<p><code>chmod +x todo.ts<\/code><\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0441\u043f\u0440\u0430\u0432\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c:<\/p>\n<p>  <\/p>\n<p><code>.\/todo.ts help<\/code><\/p>\n<p>  <\/p>\n<h2 id=\"standartnyy-vyvod\">\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434<\/h2>\n<p>  <\/p>\n<p>\u0412 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0435 \u0432\u044b\u0448\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 <code>console.log()<\/code>, \u043d\u043e, \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0438\u0434\u0435\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438 log \u2013 \u044d\u0442\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430, \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f.<\/p>\n<p>  <\/p>\n<p>\u0412 Deno \u0437\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 <code>Deno.stdout<\/code>, \u0437\u0430 \u0432\u0432\u043e\u0434, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, <code>Deno.stdin<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/** A handle for `stdin`. *\/ export const stdin: Reader &amp; ReaderSync &amp; Closer &amp; { rid: number }; \/** A handle for `stdout`. *\/ export const stdout: Writer &amp; WriterSync &amp; Closer &amp; { rid: number };<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 <code>stdin<\/code>, \u0438 <code>stdout<\/code> \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0433\u043e <code>rid<\/code>, \u2013 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0440\u0435\u0441\u0443\u0440\u0441\u0430.<\/p>\n<p>  <\/p>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c <code>stdout<\/code> \u0438 \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u00abHello world!\u00bb \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const textEncoder = new TextEncoder();  const message: string = &quot;Hello world!\\n&quot;; const encodedMessage: Uint8Array = textEncoder.encode(message);  await Deno.stdout.write(encodedMessage);<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0441\u043a\u0440\u0438\u043f\u0442 hello.ts:<\/p>\n<p>  <\/p>\n<p><code>deno run hello.ts<\/code><\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0448 \u00abHello world!\u00bb.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">export interface Writer {   write(p: Uint8Array): Promise&lt;number&gt;; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>Deno.stdout.write<\/code> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u0430\u0439\u0442\u043e\u0432 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0431\u0430\u0439\u0442\u043e\u0432. <code>Deno.stdout.writeSync<\/code> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a \u0436\u0435, \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e. <\/p>\n<p>  <\/p>\n<p>\u0421\u0442\u0440\u043e\u043a\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>TextEncoder<\/code>.<br \/>  \u041c\u043e\u0436\u043d\u043e \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c <code>TextEncoder<\/code>, \u0430 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>encode<\/code> \u0438\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0435\u043b\u0430\u0435\u0442 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a \u0436\u0435.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">import { encode } from 'https:\/\/deno.land\/std\/encoding\/utf8.ts';<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u043d\u0438\u044f\u043c\u0438 \u0438 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <code>terminal.ts<\/code> \u0441 \u0434\u0432\u0443\u043c\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 <code>print<\/code> \u0438 <code>printLines<\/code>. \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442 \u043a\u0430\u0440\u0435\u0442\u043a\u0443.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">import { encode } from &quot;https:\/\/deno.land\/std\/encoding\/utf8.ts&quot;;  export async function print(message: string) {   await Deno.stdout.write(encode(message)); }  export async function printLines(message: string) {   await print(message + &quot;\\n&quot;); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0430\u043c\u0435\u043d\u0438\u043c <code>console.log<\/code> \u043d\u0430 <code>printLines<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">#!\/usr\/bin\/env deno run  import { help } from &quot;.\/src\/ui.ts&quot;; import { printLines } from &quot;.\/src\/Terminal.ts&quot;;  const [command, ...args] = Deno.args;  switch (command) {   case &quot;help&quot;:     await printLines(help); }<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"chtenie-i-zapis-fayla\">\u0427\u0442\u0435\u043d\u0438\u0435 \u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u0444\u0430\u0439\u043b\u0430<\/h2>\n<p>  <\/p>\n<p>\u0412 Deno \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>Deno.readFile<\/code> \u0438 \u0435\u0451 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u043e\u0433 <code>Deno.readFileSync<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function Deno.readFile(path: string | URL): Promise&lt;Uint8Array&gt;<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"javascript\">const decoder = new TextDecoder(&quot;utf-8&quot;); const data = await Deno.readFile(&quot;hello.txt&quot;); console.log(decoder.decode(data));<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u0444\u0430\u0439\u043b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f <code>Deno.writeFile<\/code> \u0438 <code>Deno.writeFileSync<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function Deno.writeFile(path: string | URL, data: Uint8Array, options?: WriteFileOptions): Promise&lt;void&gt;<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"javascript\">const encoder = new TextEncoder(); const data = encoder.encode(&quot;Hello world\\n&quot;); await Deno.writeFile(&quot;hello1.txt&quot;, data);  \/\/ overwrite &quot;hello1.txt&quot; or create it<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 Deno \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439: <a href=\"https:\/\/deno.land\/std\/fs\">https:\/\/deno.land\/std\/fs<\/a>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0434 \u0432\u044b\u0448\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u0430\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 <code>readFileStr<\/code> \u0438 <code>writeFileStr<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>Task<\/code> \u0432 <code>src\/Task.ts<\/code><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">export interface Task {    title: string;   isDone: boolean; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0438 \u043a\u043b\u0430\u0441\u0441 <code>Todo<\/code> \u0432 \u0444\u0430\u0439\u043b\u0435 <code>src\/Todo.ts<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">import {   writeJsonSync,   readJsonSync,  } from &quot;https:\/\/deno.land\/std\/fs\/mod.ts&quot;;  import { Task } from &quot;.\/Task.ts&quot;;  export class Todo {   tasks: Task[] = [];    constructor(private file: string = &quot;tasks.json&quot;) {     this.open();   }    open() {     try {       this.tasks = readJsonSync(this.file) as Task[];     } catch (e) {       console.log(e);       this.tasks = [];     }   }    save() {     writeJsonSync(this.file, this.tasks, { spaces: 2 });   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 json-\u0444\u0430\u0439\u043b\u0430\u043c\u0438.<\/p>\n<p>  <\/p>\n<h2 id=\"dobavlenie-zadachi-v-spisok\">\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a<\/h2>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b <code>todo add &quot;implement add command&quot;<\/code> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043a\u043b\u0430\u0441\u0441 <code>Todo<\/code> \u043c\u0435\u0442\u043e\u0434 <code>add<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">add(title: string) {     const task: Task = {         title,         isDone: false     };      this.tasks.push(task);     this.save(); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0444\u0430\u0439\u043b, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0430 <code>--allow-read --allow-write<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">#!\/usr\/bin\/env deno run --allow-read --allow-write   import { help } from &quot;.\/src\/ui.ts&quot;; import { printLines } from &quot;.\/src\/terminal.ts&quot;; import { Todo } from &quot;.\/src\/Todo.ts&quot;;  const [command, ...args] = Deno.args;  const todo = new Todo();  switch (command) {   case &quot;help&quot;:     await printLines(help);     break;    case &quot;add&quot;:     todo.add(args[0]); }<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"vyvod-spiska-zadach\">\u0412\u044b\u0432\u043e\u0434 \u0441\u043f\u0438\u0441\u043a\u0430 \u0437\u0430\u0434\u0430\u0447<\/h2>\n<p>  <\/p>\n<p>\u0412 \u0444\u0430\u0439\u043b <code>src\/ui.ts<\/code> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0437\u0430\u0434\u0430\u0447.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">import { Task } from &quot;.\/Task.ts&quot;; import { green, red, yellow, bold } from &quot;https:\/\/deno.land\/std\/fmt\/colors.ts&quot;;  export function formatTaskList(tasks: Task[]): string {   const title = `${bold(&quot;TODO LIST:&quot;)}`;    const list = tasks.map((task, index) =&gt; {     const number = yellow(index.toString());     const checkbox = task.isDone ? green(&quot;[*]&quot;) : red(&quot;[ ]&quot;);      return `${number} ${checkbox} ${task.title}`;   });    const lines = [     title,     ...list,   ];    return lines.join(&quot;\\n&quot;); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0441\u0442\u0438\u043b\u044f \u0438 \u0446\u0432\u0435\u0442\u0430 \u0442\u0435\u043a\u0441\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0437 <a href=\"https:\/\/deno.land\/std\/fmt\/colors.ts\">https:\/\/deno.land\/std\/fmt\/colors.ts<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <code>list<\/code> \u0432 \u043a\u043b\u0430\u0441\u0441 <code>Todo<\/code> \u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>ls<\/code> \u0432 \u0441\u0432\u0438\u0442\u0447.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async list() {   await printLines(formatTaskList(this.tasks)); }<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"javascript\">case &quot;ls&quot;:   await todo.list();   break;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u0436\u0435 \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">done(index: number): void {   const task = this.tasks[index];    if (task) {     task.isDone = true;     this.save();   } }  undone(index: number): void {   const task = this.tasks[index];    if (task) {     task.isDone = false;     this.save();   } }  edit(index: number, title: string) {   const task = this.tasks[index];    if (task) {     task.title = title;     this.save();   } }  remove(index: number) {   this.tasks.splice(index);   this.save(); }<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"javascript\">case &quot;edit&quot;: \/\/ todo edit 1 &quot;edit second task&quot;   await todo.edit(parseInt(args[0], 10), args[1]);   break;  case &quot;done&quot; : \/\/ todo done 1   todo.done(parseInt(args[0], 10));   break;  case &quot;undone&quot; : \/\/ todo undone 1   todo.undone(parseInt(args[0], 10));   break;  case &quot;remove&quot; : \/\/ todo remove 1   todo.remove(parseInt(args[0], 10));   break;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0442 \u043f\u0435\u0440\u0432\u044b\u043c \u0442\u0440\u0451\u043c \u043f\u0443\u043d\u043a\u0442\u0430\u043c \u043d\u0430\u0448\u0438\u0445 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<h2 id=\"rabota-v-interaktivnom-rezhime\">\u0420\u0430\u0431\u043e\u0442\u0430 \u0432 \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435<\/h2>\n<p>  <\/p>\n<p>\u0418\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0440\u0435\u0436\u0438\u043c \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043e\u0431\u0449\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c, \u043d\u0435 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u044f\u0441\u044c \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b.<\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u0441\u0432\u0438\u0442\u0447\u0435 \u043a\u0435\u0439\u0441 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e,<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">default:   await todo.interactive();<\/code><\/pre>\n<p>  <\/p>\n<p>\u0430 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <code>Todo<\/code> \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <code>interactive<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">async interactive() {   while (true) {     \/\/ show list     \/\/ read keypress      \/\/ do action   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>interactive<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f \u043e\u0442\u0432\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043d\u0430\u0436\u0430\u0442\u043e\u0439 \u043a\u043b\u0430\u0432\u0438\u0448\u0438, \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u0443\u0440\u0441\u043e\u0440\u043e\u043c \u0432 \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <code>cursor<\/code>.<br \/>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0440\u0430\u0432\u0430 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u044d\u043d\u0432\u0430\u0439\u0440\u043e\u043d\u043c\u0435\u043d\u0442\u0443, \u0442\u0430\u043a \u043a\u0430\u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0432 \u043a\u0430\u043a\u043e\u043c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u0430 <code>--allow-env<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">import { clearDown, goUp, goLeft } from &quot;https:\/\/denopkg.com\/iamnathanj\/cursor@v2.0.0\/mod.ts&quot;;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0444\u0430\u0439\u043b\u0435 <code>terminal.ts<\/code> \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>printInteractive<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">export async function printInteractive(message: string) {   const lines = message.split(&quot;\\n&quot;);   const numberOfLines = lines.length;   const lengthOfLastLine = lines[numberOfLines - 1].length;    await clearDown();   await print(message);   await goLeft(lengthOfLastLine);    if (numberOfLines &gt; 1) {     await goUp(numberOfLines - 1);   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u043d\u0430 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u0443\u0440\u0441\u043e\u0440 \u0432 \u043d\u0430\u0447\u0430\u043b\u043e. \u041f\u0440\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0432\u044b\u0437\u043e\u0432\u0435 \u0432\u0441\u0451 \u0441\u0442\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0438 \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u043d\u043e\u0432\u043e. \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u043a\u0443\u0440\u0441\u043e\u0440\u0430 \u043d\u0435 \u043c\u0435\u0448\u0430\u043b\u0441\u044f, \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0440\u044b\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>hideCursor<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u0444\u0430\u0439\u043b <code>ui.ts<\/code> \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443 <code>toolbar<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const toolbar = `${yellow(&quot;d&quot;)}one ${yellow(&quot;a&quot;)}dd ${yellow(&quot;e&quot;)}dit ${yellow(&quot;r&quot;)}emove`;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>formatTaskList<\/code> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>showToolbar<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">export function formatTaskList(tasks: Task[], showToolbar: boolean): string { \/\/ ... if (showToolbar) {   lines.push(toolbar); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0444\u043b\u0430\u0433\u0430 <code>showToolbar<\/code> \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0443.<\/p>\n<p>  <\/p>\n<p>\u0414\u043e\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <code>list<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async list(interactive: boolean = false) {   if (interactive) {     await printInteractive(formatTaskList(this.tasks, true));   } else {     await printLines(formatTaskList(this.tasks, false));   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u044b\u0432\u043e\u0434 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d, \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0432\u0432\u043e\u0434\u0443.<\/p>\n<p>  <\/p>\n<h2 id=\"standartnyy-vvod\">\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0432\u0432\u043e\u0434<\/h2>\n<p>  <\/p>\n<p>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0432\u0432\u043e\u0434\u0430, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0432\u044b\u0432\u043e\u0434\u0443 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 <code>Uint8Array<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <code>TextDecoder<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const textDecoder = new TextDecoder(); const buffer: Uint8Array = new Uint8Array(1024);  const n: number = &lt;number&gt;await Deno.stdin.read(buffer); const message: string = textDecoder.decode(buffer.subarray(0, n));<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0431\u0443\u0444\u0435\u0440 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 1024 \u0431\u0430\u0439\u0442\u0430. \u041f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u0435\u0433\u043e \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>Deno.stdin.read<\/code> \u0438 \u0436\u0434\u0451\u043c \u043f\u043e\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442 \u0432\u0432\u043e\u0434. \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0436\u0430\u0442\u0430 \u043a\u043b\u0430\u0432\u0438\u0448\u0430 enter, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u0442 \u0431\u0443\u0444\u0435\u0440 \u0438 \u0432\u0435\u0440\u043d\u0451\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0445 \u0431\u0430\u0439\u0442\u043e\u0432. \u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0440\u043e\u043a\u0438 \u00ab\\n\u00bb \u0431\u0443\u0434\u0435\u0442 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043d\u043d\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u041e\u0431\u0440\u0435\u0437\u0430\u0435\u043c \u043b\u0438\u0448\u043d\u0435\u0435 \u0438 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443. \u0421\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>Deno.stdin.readSync<\/code> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e.<\/p>\n<p>  <\/p>\n<h2 id=\"obrabotka-klavish\">\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043a\u043b\u0430\u0432\u0438\u0448<\/h2>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043a\u043b\u0430\u0432\u0438\u0448, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>Deno.setRaw<\/code>. \u041d\u0430 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043e\u043d\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u043f\u043e\u0434 \u0444\u043b\u0430\u0433\u043e\u043c <code>--unstable<\/code>. <code>setRaw<\/code> \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443, \u0431\u0435\u0437 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0440\u0435\u0441\u0443\u0440\u0441\u0430 \u0438 \u0444\u043b\u0430\u0433. \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u044d\u0442\u0438\u043c \u0440\u0435\u0436\u0438\u043c\u043e\u043c, \u043d\u0430\u0436\u0430\u0442\u0438\u0435 CTRL+C \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0451\u0442 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u043a \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0438 \u044d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">Deno.setRaw(Deno.stdin.rid, true); const length = &lt;number&gt; await Deno.stdin.read(buffer); Deno.setRaw(Deno.stdin.rid, false);<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0444\u0430\u0439\u043b <code>terminal.ts<\/code> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>readKeypress<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">export async function readKeypress(): Promise&lt;string&gt; {   const buffer = new Uint8Array(1024);   Deno.setRaw(Deno.stdin.rid, true);   const length = &lt;number&gt; await Deno.stdin.read(buffer);   Deno.setRaw(Deno.stdin.rid, false);    return decode(buffer.subarray(0, length)); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043c\u0435\u0442\u043e\u0434 interactive \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0439\u0442\u0438 \u0438\u0437 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">async interactive() {   while (true) {     await this.list(true);     const key = await readKeypress();      if (key == &quot;\\u0003&quot;) { \/\/ ctrl-c       Deno.exit();     }   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0435 \u043e\u0442\u0445\u043e\u0434\u044f \u0434\u0430\u043b\u0435\u043a\u043e \u043e\u0442 \u0432\u0432\u043e\u0434\u0430 \u0442\u0435\u043a\u0441\u0442\u0430, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0444\u0430\u0439\u043b <code>terminal.ts<\/code> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c 2 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">export async function readLine(): Promise&lt;string&gt; {   const buffer = new Uint8Array(1024);   const length = &lt;number&gt; await Deno.stdin.read(buffer);   return decode(buffer.subarray(0, length - 1)); }  export async function prompt(question: string): Promise&lt;string&gt; {   await clearDown();   await print(question);   const answer = await readLine();   await goLeft(question.length + answer.length);   await goUp(1);    return answer; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>readLine<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443, \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0441\u0438\u043c\u0432\u043e\u043b, \u2013 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n<p>  <\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>prompt<\/code> \u043e\u0447\u0438\u0449\u0430\u0435\u0442 \u044d\u043a\u0440\u0430\u043d, \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441, \u0447\u0438\u0442\u0430\u0435\u0442 \u0432\u0432\u043e\u0434 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u0442 \u043a\u0443\u0440\u0441\u043e\u0440 \u0432 \u043d\u0430\u0447\u0430\u043b\u043e, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>printInteractive<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0412 \u043c\u0435\u0442\u043e\u0434 <code>interactive<\/code> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043a\u043b\u0430\u0432\u0438\u0448\u0438 \u00ab\u0430\u00bb:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">if (key === &quot;a&quot;) {   const title = await prompt(&quot;Add task: &quot;);    if (title) {     await this.add(title);   } }<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"peremeschenie-po-spisku-zadach\">\u041f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443 \u0437\u0430\u0434\u0430\u0447<\/h2>\n<p>  <\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0441\u0442\u0440\u0435\u043b\u043e\u043a \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u044b. \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u043a\u0430\u043a\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u0435\u0439\u0447\u0430\u0441 \u0432\u044b\u0431\u0440\u0430\u043d, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>currentIndex<\/code> \u0432 \u043a\u043b\u0430\u0441\u0441 <code>Todo<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">  private currentIndex: number = 0;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0410 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>formatTaskList<\/code> \u0430\u043a\u0442\u0438\u0432\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u043c \u0436\u0438\u0440\u043d\u044b\u043c \u0438 \u043a\u0440\u0430\u0441\u0438\u043c \u0432 \u0436\u0451\u043b\u0442\u044b\u0439:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">export function formatTaskList(   tasks: Task[],   showToolbar: boolean = false,   activeIndex?: number, ): string {   const title = `${bold(&quot;TODO LIST:&quot;)}`;    const list = tasks.map((task, index) =&gt; {     \/\/ ...     const isActive = activeIndex === index;     const title = isActive ? bold(yellow(task.title)) : task.title;      return `${number} ${checkbox} ${title}`;   });    \/\/ ... }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 <code>Todo<\/code> \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c <code>currentIndex<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">up() {   this.currentIndex = this.currentIndex === 0     ? this.tasks.length - 1     : this.currentIndex - 1; }  down() {   this.currentIndex = this.currentIndex === this.tasks.length - 1     ? 0     : this.currentIndex + 1; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043c\u0435\u0442\u043e\u0434 <code>interactive<\/code> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0441\u0442\u0440\u0435\u043b\u043e\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">if (key === &quot;\\u001B\\u005B\\u0041&quot; || key === &quot;\\u001B\\u005B\\u0044&quot;) { \/\/ \u0432\u0432\u0435\u0440\u0445 \u0438\u043b\u0438 \u0432\u043b\u0435\u0432\u043e   this.up(); } else if (key === &quot;\\u001B\\u005B\\u0042&quot; || key === &quot;\\u001B\\u005B\\u0043&quot;) { \/\/ \u0432\u043d\u0438\u0437 \u0438\u043b\u0438 \u0432\u043f\u0440\u0430\u0432\u043e   this.down(); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043c\u0435\u0447\u0430\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">toggle(index: number = this.currentIndex) {   const task = this.tasks[index];    if (task) {     task.isDone = !task.isDone;     this.save();   } }<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">if (key === &quot;d&quot; || key === &quot; &quot;) {     this.toggle(); } else if ('0' &lt;= key &amp;&amp; key &lt;= '9') {     this.toggle(parseInt(key, 10)); } <\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043e\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">remove(index: number = this.currentIndex) {   if (index === this.tasks.length - 1) {     this.up();   }    this.tasks.splice(index, 1);   this.save(); }<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"javascript\">if (key === &quot;r&quot;) {     this.remove(); } <\/code><\/pre>\n<p>  <\/p>\n<p>\u0418, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">if (key === &quot;e&quot;) {   if (!this.tasks[this.currentIndex]) {     return;   }    const title = await prompt(&quot;Edit task (&quot; + this.tasks[this.currentIndex].title + &quot;): &quot;);    if (title) {     this.edit(this.currentIndex, title);   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">deno run --allow-read --allow-write --allow-env --unstable .\/todo.ts<\/code><\/pre>\n<p>  <\/p>\n<p>\u0438\u043b\u0438<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">.\/todo.ts<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"ustanovka\">\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/h2>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u0431\u044b \u043d\u0430\u0448\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0431\u044b\u043b\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>deno install<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">deno install --allow-read --allow-write --allow-env --unstable .\/todo.ts<\/code><\/pre>\n<p>  <\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430, \u0442\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u0438 \u0437\u0430\u043f\u0443\u0441\u043a, \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043f\u043e URL.<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">deno install --allow-read --allow-write --allow-env --unstable  https:\/\/raw.githubusercontent.com\/dmitriytat\/todo\/master\/todo.ts<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043e \u043a\u0430\u043a \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0446\u0438\u0438 -n\/&#8212;name \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0435.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e <code>todo<\/code> \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435.<\/p>\n<p>  <\/p>\n<h2 id=\"import-zavisimostey\">\u0418\u043c\u043f\u043e\u0440\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439<\/h2>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0444\u0438\u0447\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438, \u043d\u043e \u0435\u0449\u0451 \u043d\u0435 \u043e\u0431\u0441\u0443\u0434\u0438\u043b\u0438 \u2013 \u0438\u043c\u043f\u043e\u0440\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 Node, \u0432 Deno \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u043e\u0439: \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043f\u043e URL. \u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0435\u0441\u0442\u044c \u043a\u0430\u043a \u0434\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430, \u0442\u0430\u043a \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043e\u0434\u043d\u043e\u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0445 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e URL \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u043c \u043f\u043b\u044e\u0441\u043e\u043c, \u043d\u043e \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0447\u0442\u043e-\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u0435, \u0443\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0432\u0435\u0440\u0441\u0438\u044f\u043c\u0438 \u0441\u0442\u0430\u043d\u0435\u0442 \u0442\u0440\u0443\u0434\u043d\u0435\u0435.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0432\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f: \u0444\u0430\u0439\u043b <code>dep.ts<\/code> \u0438 \u0444\u0430\u0439\u043b \u0441 \u043a\u0430\u0440\u0442\u043e\u0439 \u0438\u043c\u043f\u043e\u0440\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0440\u0435\u044d\u043a\u0441\u043f\u043e\u0440\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0441\u043e\u0431\u0438\u0440\u0430\u044f \u0432\u0441\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u044b \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">export { green, red, yellow, bold } from &quot;https:\/\/deno.land\/std@0.55.0\/fmt\/colors.ts&quot;; export { decode, encode } from &quot;https:\/\/deno.land\/std@v0.55.0\/encoding\/utf8.ts&quot;; export { clearDown, goUp, goLeft } from &quot;https:\/\/denopkg.com\/iamnathanj\/cursor@v2.0.0\/mod.ts&quot;; <\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432 JSON \u0444\u0430\u0439\u043b\u0435 \u043c\u044b \u043f\u0438\u0448\u0435\u043c alias:<\/p>\n<p>  <\/p>\n<p><code>import_map.json<\/code><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">{    &quot;imports&quot;: {       &quot;fmt\/&quot;: &quot;https:\/\/deno.land\/std@0.55.0\/fmt\/&quot;    } }<\/code><\/pre>\n<p>  <\/p>\n<p><code>color.ts<\/code><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">import { red } from &quot;fmt\/colors.ts&quot;;  console.log(red(&quot;hello world&quot;));<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043f\u0443\u0442\u044c \u0434\u043e \u043a\u0430\u0440\u0442\u044b \u0438 \u0444\u043b\u0430\u0433 &#8212;unstable, \u0442\u0430\u043a \u043a\u0430\u043a \u0444\u0438\u0447\u0430 \u043d\u0435 \u0433\u043e\u0442\u043e\u0432\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0430.<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">deno run --importmap=import_map.json --unstable color.ts.<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"rezyume\">\u0420\u0435\u0437\u044e\u043c\u0435<\/h2>\n<p>  <\/p>\n<p>\u0412 \u0446\u0435\u043b\u043e\u043c, \u0440\u0430\u0431\u043e\u0442\u043e\u0439 Deno \u044f \u0434\u043e\u0432\u043e\u043b\u0435\u043d. \u041d\u043e\u0432\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0435 \u0442\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0438 \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u043a\u043e\u0434\u0430, \u0447\u0442\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e.<br \/>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u044f \u043c\u043e\u0433\u0443 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u0442\u044c Deno \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c, \u0443\u043f\u0440\u043e\u0449\u0430\u044e\u0449\u0438\u0445 \u0436\u0438\u0437\u043d\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430, \u043d\u043e \u043f\u043e\u043a\u0430 \u0432\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u043b\u0441\u044f \u0431\u044b \u043e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Deno \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439.<\/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\/company\/funcorp\/blog\/507282\/\"> https:\/\/habr.com\/ru\/company\/funcorp\/blog\/507282\/<\/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\/company\/funcorp\/blog\/507282\/\">\n<p>\u0412\u044b \u0443\u0436\u0435 \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0441\u043b\u044b\u0448\u0430\u043b\u0438 \u043f\u0440\u043e Deno \u0438, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043b\u0438 \u043f\u0430\u0440\u0443-\u0442\u0440\u043e\u0439\u043a\u0443 \u043e\u0431\u0437\u043e\u0440\u043e\u0432. \u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0441\u0432\u043e\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0438\u0441\u043f\u044b\u0442\u0430\u0442\u044c Deno \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435, \u043d\u0430\u043f\u0438\u0441\u0430\u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u043f\u043e\u043f\u0443\u0442\u043d\u043e \u0440\u0430\u0437\u043c\u044b\u0448\u043b\u044f\u044f \u043e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430\u0445 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u0445 \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u0432\u043e\u0434\u043e\u043c \u0438 \u0432\u044b\u0432\u043e\u0434\u043e\u043c \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ng\/px\/c6\/ngpxc6lniysqyciixbblngga_vk.jpeg\"><\/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-305780","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/305780","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=305780"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/305780\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=305780"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=305780"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=305780"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}