{"id":297527,"date":"2020-01-22T21:00:17","date_gmt":"2020-01-22T21:00:17","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=297527"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=297527","title":{"rendered":"\u0427\u0438\u0441\u0442\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f TypeScript \u2014 \u0427\u0430\u0441\u0442\u044c 2"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/485068\/\">\n<p><a href=\"https:\/\/habr.com\/ru\/post\/484402\/\">\u041f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/a>, \u0441\u0443\u0434\u044f \u043f\u043e \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c \u0432\u044b\u0437\u0432\u0430\u043b\u0430 \u043d\u0435\u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0435 \u043c\u043d\u0435\u043d\u0438\u0435, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0447\u0442\u043e \u043a\u0430\u0441\u0430\u043b\u043e\u0441\u044c \u0447\u0430\u0441\u0442\u0438 enum. \u0413\u0434\u0435-\u0442\u043e \u044f \u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0433\u0443 \u043d\u0435 \u0441\u043e\u0433\u043b\u0430\u0448\u0430\u0442\u044c\u0441\u044f, \u043a\u0430\u043a \u0441 \u0430\u0432\u0442\u043e\u0440\u043e\u043c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u0430, \u0442\u0430\u043a \u0438 \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438. \u041d\u043e \u043a\u0430\u043a \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u043e\u0441\u044c \u0432 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043a \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u0447\u0438\u0441\u0442\u044b\u0439 \u043a\u043e\u0434 \u044d\u0442\u043e \u043d\u0435 \u0434\u043e\u0433\u043c\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0431\u043b\u044e\u0434\u0430\u0442\u044c, \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438, \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0430\u043c \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u043e\u0434 \u0441\u0432\u043e\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0438 \u0438 \u0432\u0437\u0433\u043b\u044f\u0434\u044b. <\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/z9\/8a\/ud\/z98audmtqbuxlujlrwtdfjmnduo.png\"><\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h1 id=\"obekty-i-struktury-dannyh\">\u041e\u0431\u044a\u0435\u043a\u0442\u044b \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/h1>\n<p>  <\/p>\n<h2 id=\"ispolzuyte-immutabelnost\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/h2>\n<p>  <\/p>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0442\u0438\u043f\u043e\u0432 \u0432 TypeScript \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043c\u0435\u0447\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\/\u043a\u043b\u0430\u0441\u0441\u0430 \u043a\u0430\u043a <em>readonly \u043f\u043e\u043b\u044f (\u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f)<\/em>. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0430\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e (\u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u0430\u044f \u043c\u0443\u0442\u0430\u0446\u0438\u044f \u044d\u0442\u043e \u043f\u043b\u043e\u0445\u043e). \u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432 \u0435\u0441\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u0442\u0438\u043f <code>Readonly<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u0438\u043f<code>T<\/code> \u0438 \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u0442 \u0432\u0441\u0435 \u0435\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c mapped types (\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 <a href=\"https:\/\/www.typescriptlang.org\/docs\/handbook\/advanced-types.html#mapped-types\">mapped types<\/a>).<\/p>\n<p>  <\/p>\n<p><strong>\u041f\u043b\u043e\u0445\u043e:<\/strong><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">interface Config {   host: string;   port: string;   db: string; }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u0425\u043e\u0440\u043e\u0448\u043e:<\/strong><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">interface Config {   readonly host: string;   readonly port: string;   readonly db: string; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <code>ReadonlyArray&lt;T&gt;<\/code>. \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c <code>push()<\/code> \u0438 <code>fill()<\/code>, \u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>concat()<\/code> \u0438 <code>slice()<\/code> \u043e\u043d\u0438 \u043d\u0435 \u043c\u0435\u043d\u044f\u044e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p><strong>\u041f\u043b\u043e\u0445\u043e:<\/strong><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const array: number[] = [ 1, 3, 5 ]; array = []; \/\/ error array.push(100); \/\/ array will updated<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u0425\u043e\u0440\u043e\u0448\u043e:<\/strong><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const array: ReadonlyArray&lt;number&gt; = [ 1, 3, 5 ]; array = []; \/\/ error array.push(100); \/\/ error<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/wiki\/What%5E_%5E039%5E_%5Es-new-in-TypeScript#improvements-for-readonlyarray-and-readonly-tuples\">TypeScript 3.4 is a bit easier<\/a>.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function hoge(args: readonly string[]) {   args.push(1); \/\/ error }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0435\u043d\u0438\u0435 <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/wiki\/What%5E_%5E039%5E_%5Es-new-in-TypeScript#const-assertions\">const assertions<\/a> \u0434\u043b\u044f \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<p><strong>\u041f\u043b\u043e\u0445\u043e:<\/strong><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">const config = {   hello: 'world' }; config.hello = 'world'; \/\/ \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043e  const array  = [ 1, 3, 5 ]; array[0] = 10; \/\/ \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043e  \/\/ \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442\u0441\u044f function readonlyData(value: number) {   return { value }; }  const result = readonlyData(100); result.value = 200; \/\/ \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043e<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u0425\u043e\u0440\u043e\u0448\u043e:<\/strong><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ \u043e\u0431\u044a\u0435\u043a\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f const config = {   hello: 'world' } as const; config.hello = 'world'; \/\/ \u043e\u0448\u0438\u0431\u043a\u0430  \/\/ \u043c\u0430\u0441\u0441\u0438\u0432 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f const array  = [ 1, 3, 5 ] as const; array[0] = 10; \/\/ \u043e\u0448\u0438\u0431\u043a\u0430  \/\/ \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f function readonlyData(value: number) {   return { value } as const; }  const result = readonlyData(100); result.value = 200; \/\/ \u043e\u0448\u0438\u0431\u043a\u0430<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"tipy-vs-interfeysy\">\u0422\u0438\u043f\u044b vs. \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b<\/h2>\n<p>  <\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0442\u0438\u043f\u044b, \u043a\u043e\u0433\u0434\u0430 \u0432\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043a\u043e\u0433\u0434\u0430 \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>extends<\/code> \u0438\u043b\u0438 <code>implements<\/code>. \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u0442\u0440\u043e\u0433\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0442\u043e, \u0447\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0443 \u0432\u0430\u0441. \u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u044d\u0442\u043e <a href=\"https:\/\/stackoverflow.com\/questions\/37233735\/typescript-interfaces-vs-types\/54101543#54101543\">\u043e\u0442\u0432\u0435\u0442\u044b<\/a> \u043e \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f\u0445 \u043c\u0435\u0436\u0434\u0443 <code>type<\/code> and <code>interface<\/code> \u0432 TypeScript.<\/p>\n<p>  <\/p>\n<p><strong>\u041f\u043b\u043e\u0445\u043e:<\/strong><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">interface EmailConfig {   \/\/ ... }  interface DbConfig {   \/\/ ... }  interface Config {   \/\/ ... }  \/\/...  type Shape = {   \/\/ ... }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u0425\u043e\u0440\u043e\u0448\u043e:<\/strong><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\"> type EmailConfig = {   \/\/ ... }  type DbConfig = {   \/\/ ... }  type Config  = EmailConfig | DbConfig;  \/\/ ...  interface Shape {   \/\/ ... }  class Circle implements Shape {   \/\/ ... }  class Square implements Shape {   \/\/ ... }<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"klassy\">\u041a\u043b\u0430\u0441\u0441\u044b<\/h1>\n<p>  <\/p>\n<h2 id=\"klassy-dolzhny-byt-malenkimi\">\u041a\u043b\u0430\u0441\u0441\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u043c\u0438<\/h2>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u043c\u0435\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u0437\u043c\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0435\u0433\u043e \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e. \u0421\u043b\u0435\u0434\u0443\u044f <em>\u041f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438<\/em> \u043a\u043b\u0430\u0441\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u043c.<\/p>\n<p>  <\/p>\n<p><strong>\u041f\u043b\u043e\u0445\u043e:<\/strong><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class Dashboard {   getLanguage(): string { \/* ... *\/ }   setLanguage(language: string): void { \/* ... *\/ }   showProgress(): void { \/* ... *\/ }   hideProgress(): void { \/* ... *\/ }   isDirty(): boolean { \/* ... *\/ }   disable(): void { \/* ... *\/ }   enable(): void { \/* ... *\/ }   addSubscription(subscription: Subscription): void { \/* ... *\/ }   removeSubscription(subscription: Subscription): void { \/* ... *\/ }   addUser(user: User): void { \/* ... *\/ }   removeUser(user: User): void { \/* ... *\/ }   goToHomePage(): void { \/* ... *\/ }   updateProfile(details: UserDetails): void { \/* ... *\/ }   getVersion(): string { \/* ... *\/ }   \/\/ ... }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u0425\u043e\u0440\u043e\u0448\u043e:<\/strong><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class Dashboard {   disable(): void { \/* ... *\/ }   enable(): void { \/* ... *\/ }   getVersion(): string { \/* ... *\/ } }  \/\/ \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0431\u044f\u0437\u0430\u043d\u043d\u043e\u0441\u0442\u0438, \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0432 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u044b \u0432 \u0434\u0440\u0443\u0433\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \/\/ ...<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"vysokaya-splochennost-nizkaya-svyaz\">\u0412\u044b\u0441\u043e\u043a\u0430\u044f \u0441\u043f\u043b\u043e\u0447\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043d\u0438\u0437\u043a\u0430\u044f \u0441\u0432\u044f\u0437\u044c<\/h2>\n<p>  <\/p>\n<p>\u0421\u043f\u043b\u043e\u0447\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0441\u0442\u0435\u043f\u0435\u043d\u044c, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0447\u043b\u0435\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c. \u0412 \u0438\u0434\u0435\u0430\u043b\u0435 \u0432\u0441\u0435 \u043f\u043e\u043b\u044f \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c. \u041c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c, \u0447\u0442\u043e \u043a\u043b\u0430\u0441\u0441 <em>\u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0441\u0432\u044f\u0437\u043d\u044b\u0439<\/em>. \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u044d\u0442\u043e, \u043e\u0434\u043d\u0430\u043a\u043e, \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0438 \u0434\u0430\u0436\u0435 \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u041e\u0434\u043d\u0430\u043a\u043e \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0434\u043e\u0431\u0438\u0432\u0430\u0442\u044c\u0441\u044f, \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0441\u043f\u043b\u043e\u0447\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0431\u044b\u043b\u0430 \u0432\u044b\u0441\u043e\u043a\u043e\u0439. <\/p>\n<p>  <\/p>\n<p>\u0421\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u0438 \u043a \u0442\u043e\u043c\u0443, \u043a\u0430\u043a \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0438\u043b\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b \u0434\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430. \u041a\u043b\u0430\u0441\u0441\u044b \u0441\u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u0441\u043b\u0430\u0431\u043e\u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u0435\u0441\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043d\u0438\u0445 \u043d\u0435 \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439. <\/p>\n<p>  <\/p>\n<p><strong>\u041f\u043b\u043e\u0445\u043e:<\/strong><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class UserManager {   \/\/ \u041f\u043b\u043e\u0445\u043e: \u043a\u0430\u0436\u0434\u0430\u044f \u0437\u0430\u043a\u0440\u044b\u0442\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u0439 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u043e\u0439 \u043c\u0435\u0442\u043e\u0434\u043e\u0432.   \/\/ \u042d\u0442\u043e \u044f\u0441\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u043a\u043b\u0430\u0441\u0441 \u043d\u0435\u0441\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043e\u0434\u043d\u0443 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c   \/\/ \u0415\u0441\u043b\u0438 \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f,   \/\/ \u042f \u0432\u0441\u0435 \u0435\u0449\u0435 \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440  `emailSender`.   constructor(     private readonly db: Database,     private readonly emailSender: EmailSender) {   }    async getUser(id: number): Promise&lt;User&gt; {     return await db.users.findOne({ id });   }    async getTransactions(userId: number): Promise&lt;Transaction[]&gt; {     return await db.transactions.find({ userId });   }    async sendGreeting(): Promise&lt;void&gt; {     await emailSender.send('Welcome!');   }    async sendNotification(text: string): Promise&lt;void&gt; {     await emailSender.send(text);   }    async sendNewsletter(): Promise&lt;void&gt; {     \/\/ ...   } }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u0425\u043e\u0440\u043e\u0448\u043e:<\/strong><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class UserService {   constructor(private readonly db: Database) {   }    async getUser(id: number): Promise&lt;User&gt; {     return await this.db.users.findOne({ id });   }    async getTransactions(userId: number): Promise&lt;Transaction[]&gt; {     return await this.db.transactions.find({ userId });   } }  class UserNotifier {   constructor(private readonly emailSender: EmailSender) {   }    async sendGreeting(): Promise&lt;void&gt; {     await this.emailSender.send('Welcome!');   }    async sendNotification(text: string): Promise&lt;void&gt; {     await this.emailSender.send(text);   }    async sendNewsletter(): Promise&lt;void&gt; {     \/\/ ...   } }<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"predpochitayte-kompoziciyu-nasledovaniyu\">\u041f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044e<\/h2>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0441\u043a\u0430\u0437\u0430\u043d\u043e \u0432 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Design_Patterns\">Design Patterns<\/a> \u043e\u0442 \u0431\u0430\u043d\u0434\u044b \u0447\u0435\u0440\u044b\u0442\u0435\u0445 \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b<br \/>  <em>\u041f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044e<\/em> \u0433\u0434\u0435 \u043c\u043e\u0436\u0435\u0442\u0435. \u0415\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0432\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u0438\u0447\u0438\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u043c\u043d\u043e\u0433\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0445 \u043f\u0440\u0438\u0447\u0438\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044e. \u0421\u0443\u0442\u044c \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432\u0430\u0448 \u0443\u043c \u0438\u043d\u0441\u0442\u0438\u043d\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0434\u0435\u0442 \u043d\u0430 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c, \u043c\u043e\u0436\u0435\u0442 \u043b\u0438 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044f \u043b\u0443\u0447\u0448\u0435 \u0441\u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0430\u0448\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443. \u0412 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043c\u043e\u0436\u0435\u0442. <\/p>\n<p>  <\/p>\n<p>\u0422\u043e\u0433\u0434\u0430 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u044c: &quot;\u041a\u043e\u0433\u0434\u0430 \u044f \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435?&quot; \u042d\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0432\u0430\u0448\u0435\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u043d\u043e \u044d\u0442\u043e \u0434\u043e\u0441\u0442\u043e\u0439\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0441\u043c\u044b\u0441\u043b\u0430, \u0447\u0435\u043c \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044f:<\/p>\n<p>  <\/p>\n<ol>\n<li>\u0412\u0430\u0448\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 &quot;is-a&quot; \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u0430 \u043d\u0435 &quot;has-a&quot; \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f (Human-&gt;Animal vs. User-&gt;UserDetails).<\/li>\n<li>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 \u0438\u0437 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 (\u041b\u044e\u0434\u0438 \u043c\u043e\u0433\u0443\u0442 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u0432\u0441\u0435 \u0436\u0438\u0432\u043e\u0442\u043d\u044b\u0435).<\/li>\n<li>\u0412\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0432\u043d\u0435\u0441\u0442\u0438 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u0438\u0437\u043c\u0435\u043d\u0438\u0432 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441. (\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u0430 \u043a\u0430\u043b\u043e\u0440\u0438\u0439 \u0443 \u0432\u0441\u0435\u0445 \u0436\u0438\u0432\u043e\u0442\u043d\u044b\u0445 \u043f\u0440\u0438 \u0438\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0438).<\/li>\n<\/ol>\n<p>  <\/p>\n<p><strong>\u041f\u043b\u043e\u0445\u043e:<\/strong><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class Employee {   constructor(     private readonly name: string,     private readonly email: string) {   }    \/\/ ... }  \/\/ \u041f\u043b\u043e\u0445\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e Employees &quot;\u0438\u043c\u0435\u044e\u0442&quot; \u043d\u0430\u043b\u043e\u0433\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. EmployeeTaxData \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0438\u043f\u043e\u043c  Employee class EmployeeTaxData extends Employee {   constructor(     name: string,     email: string,     private readonly ssn: string,     private readonly salary: number) {     super(name, email);   }    \/\/ ... }<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u0425\u043e\u0440\u043e\u0448\u043e:<\/strong><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class Employee {   private taxData: EmployeeTaxData;    constructor(     private readonly name: string,     private readonly email: string) {   }    setTaxData(ssn: string, salary: number): Employee {     this.taxData = new EmployeeTaxData(ssn, salary);     return this;   }    \/\/ ... }  class EmployeeTaxData {   constructor(     public readonly ssn: string,     public readonly salary: number) {   }    \/\/ ... }<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"ispolzuyte-cepochki-vyzovov\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0432\u044b\u0437\u043e\u0432\u043e\u0432<\/h2>\n<p>  <\/p>\n<p>\u042d\u0442\u043e\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u0440\u043d \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0438 \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u0445. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0430\u0448\u0435\u043c\u0443 \u043a\u043e\u0434\u0443 \u0431\u044b\u0442\u044c \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0438 \u043c\u0435\u043d\u0435\u0435 \u043c\u043d\u043e\u0433\u043e\u0441\u043b\u043e\u0432\u043d\u044b\u043c. \u041f\u043e \u044d\u0442\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0441\u0442\u044b\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u0430\u0448 \u043a\u043e\u0434.<\/p>\n<p>  <\/p>\n<p><strong>\u041f\u043b\u043e\u0445\u043e:<\/strong><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class QueryBuilder {   private collection: string;   private pageNumber: number = 1;   private itemsPerPage: number = 100;   private orderByFields: string[] = [];    from(collection: string): void {     this.collection = collection;   }    page(number: number, itemsPerPage: number = 100): void {     this.pageNumber = number;     this.itemsPerPage = itemsPerPage;   }    orderBy(...fields: string[]): void {     this.orderByFields = fields;   }    build(): Query {     \/\/ ...   } }  \/\/ ...  const queryBuilder = new QueryBuilder(); queryBuilder.from('users'); queryBuilder.page(1, 100); queryBuilder.orderBy('firstName', 'lastName');  const query = queryBuilder.build();<\/code><\/pre>\n<p>  <\/p>\n<p><strong>\u0425\u043e\u0440\u043e\u0448\u043e:<\/strong><\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">class QueryBuilder {   private collection: string;   private pageNumber: number = 1;   private itemsPerPage: number = 100;   private orderByFields: string[] = [];    from(collection: string): this {     this.collection = collection;     return this;   }    page(number: number, itemsPerPage: number = 100): this {     this.pageNumber = number;     this.itemsPerPage = itemsPerPage;     return this;   }    orderBy(...fields: string[]): this {     this.orderByFields = fields;     return this;   }    build(): Query {     \/\/ ...   } }  \/\/ ...  const query = new QueryBuilder()   .from('users')   .page(1, 100)   .orderBy('firstName', 'lastName')   .build();<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442&#8230;<\/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\/485068\/\"> https:\/\/habr.com\/ru\/post\/485068\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/485068\/\">\n<p><a href=\"https:\/\/habr.com\/ru\/post\/484402\/\">\u041f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c<\/a>, \u0441\u0443\u0434\u044f \u043f\u043e \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c \u0432\u044b\u0437\u0432\u0430\u043b\u0430 \u043d\u0435\u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0435 \u043c\u043d\u0435\u043d\u0438\u0435, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0447\u0442\u043e \u043a\u0430\u0441\u0430\u043b\u043e\u0441\u044c \u0447\u0430\u0441\u0442\u0438 enum. \u0413\u0434\u0435-\u0442\u043e \u044f \u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0433\u0443 \u043d\u0435 \u0441\u043e\u0433\u043b\u0430\u0448\u0430\u0442\u044c\u0441\u044f, \u043a\u0430\u043a \u0441 \u0430\u0432\u0442\u043e\u0440\u043e\u043c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u0430, \u0442\u0430\u043a \u0438 \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438. \u041d\u043e \u043a\u0430\u043a \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u043e\u0441\u044c \u0432 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043a \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u0447\u0438\u0441\u0442\u044b\u0439 \u043a\u043e\u0434 \u044d\u0442\u043e \u043d\u0435 \u0434\u043e\u0433\u043c\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0431\u043b\u044e\u0434\u0430\u0442\u044c, \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438, \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0430\u043c \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u043e\u0434 \u0441\u0432\u043e\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0438 \u0438 \u0432\u0437\u0433\u043b\u044f\u0434\u044b. <\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/z9\/8a\/ud\/z98audmtqbuxlujlrwtdfjmnduo.png\"><\/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-297527","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/297527","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=297527"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/297527\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=297527"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=297527"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=297527"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}