{"id":284330,"date":"2017-04-03T10:25:04","date_gmt":"2017-04-03T06:25:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=284330"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=284330","title":{"rendered":"Matreshka.js 2 \u2014 tl;dr"},"content":{"rendered":"<p><a href=\"https:\/\/ru.matreshka.io\/?c\"><img decoding=\"async\" src=\"http:\/\/matreshka.io\/img\/mk5-logo_full-vert.svg\" alt=\"image\"\/><\/a><\/p>\n<p>  <\/p>\n<p>\u041a\u0440\u0430\u0442\u043a\u0438\u0439 \u043e\u0431\u0437\u043e\u0440 Matreshka.js. \u0412 \u043f\u043e\u0441\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f ECMAScript 2017, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 ECMAScript 5.<\/p>\n<p>  <\/p>\n<h1 id=\"osnovnye-funkcii\">\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/h1>\n<p>  <\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>bindNode<\/code> \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<\/p>\n<p>  <\/p>\n<pre><code>const object = { name: 'Brendan' }; const node = document.querySelector('.name'); Matreshka.bindNode(object, 'name', node); object.name = 'Doug';<\/code><\/pre>\n<p>  <\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0px; width: 100%; height: 300px; position: relative;\"><iframe src=\"https:\/\/codepen.io\/finom\/embed\/preview\/oZmGYo?height=300&amp;amp;slug-hash=oZmGYo&amp;amp;default-tabs=js,result&amp;amp;host=http%3A%2F%2Fcodepen.io&amp;amp;embed-version=2\" frameborder=\"0\" allowfullscreen=\"true\" webkitallowfullscreen=\"true\" mozallowfullscreen=\"true\" style=\"top: 0px; left: 0px; width: 100%; height: 100%; position: absolute;\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u0435\u0441\u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u0432\u043e\u0434\u0438\u0442 \u0442\u0435\u043a\u0441\u0442), \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e. \u0418\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438 Matreshka.js \u0443\u043c\u0435\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0444\u043e\u0440\u043c. \u041c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0431\u0430\u0439\u043d\u0434\u0438\u043d\u0433 \u0434\u043b\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 <a href=\"https:\/\/ru.matreshka.io\/#!Matreshka-bindNode\">\u0441\u043c. \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>calc<\/code> \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0434\u043d\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438.<\/p>\n<p>  <\/p>\n<pre><code>Matreshka.calc(object, 'fullName', ['firstName', 'lastName'], (firstName, lastName) =&gt; {     return `${firstName} ${lastName}` }); object.firstName = 'Brendan'; object.lastName = 'Eich'; \/\/ ... console.log(object.fullName); \/\/ &quot;Brendan Eich&quot;<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a (<code>firstName<\/code> \u0438\u043b\u0438 <code>lastName<\/code>), \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e-\u0446\u0435\u043b\u044c (<code>fullName<\/code>).<\/p>\n<p>  <\/p>\n<p>\u0412\u043c\u0435\u0441\u0442\u0435 \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>bindNode<\/code> \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u0434\u043b\u0438\u043d\u043d\u044b\u0435 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439: \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>a<\/code> \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 <code>e1<\/code>, \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>b<\/code> \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>a<\/code>, \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>c<\/code> \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 <code>e2<\/code> \u0438 <code>e3<\/code> \u0438 \u043e\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>b<\/code>, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e, \u043a\u0430\u043a \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435, \u043c\u0435\u043d\u044f\u0435\u0442 <code>e1<\/code>, <code>e2<\/code> \u0438 <code>e3<\/code>&#8230;<\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0435 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Excell): \u0432 \u043a\u0430\u0436\u0434\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b \u0434\u0443\u043c\u0430\u0435\u0442\u0435 \u043e\u0431 \u043e\u0434\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0443\u043b\u0435, \u0430 \u043d\u0435 \u043e \u043c\u043d\u043e\u0433\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0432\u044f\u0437\u044f\u0445 \u0432\u0441\u0435 \u044f\u0447\u0435\u0435\u043a. \u041a\u0430\u043a \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435 \u043c\u0435\u043d\u044c\u0448\u0435 \u0431\u0430\u0433\u043e\u0432, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0443\u0436\u043d\u043e \u0434\u0443\u043c\u0430\u0442\u044c \u043e\u0431 \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u0445, \u0430 \u043d\u0435 \u043e\u0431\u043e \u0432\u0441\u0435\u0439 &quot;\u0442\u0430\u0431\u043b\u0438\u0446\u0435&quot; (\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438). \u0411\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 <a href=\"https:\/\/ru.matreshka.io\/#!Matreshka-calc\">\u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<p>  <a name=\"habracut\"><\/a>  <\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>on<\/code> \u043b\u043e\u0432\u0438\u0442, \u0430 <code>trigger<\/code> \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u044f.<\/p>\n<p>  <\/p>\n<pre><code>Matreshka.on(object, 'something', () =&gt; alert('something is happened')); Matreshka.trigger(object, 'something');<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u0441\u043b\u0443\u0448\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432, \u0447\u0442\u043e\u0431 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043a\u043e\u0434. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c, \u0441\u043a\u0430\u0436\u0435\u043c, fetch \u0437\u0430\u043f\u0440\u043e\u0441.<\/p>\n<p>  <\/p>\n<pre><code>Matreshka.on(object, 'change:fullName', async () =&gt; {    await fetch('\/api\/name', { method: 'post', body: this.fullName });    \/\/ ... })<\/code><\/pre>\n<p>  <\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0px; width: 100%; height: 300px; position: relative;\"><iframe src=\"https:\/\/codepen.io\/finom\/embed\/preview\/EWrwmW?height=300&amp;amp;slug-hash=EWrwmW&amp;amp;default-tabs=js,result&amp;amp;host=http%3A%2F%2Fcodepen.io&amp;amp;embed-version=2\" frameborder=\"0\" allowfullscreen=\"true\" webkitallowfullscreen=\"true\" mozallowfullscreen=\"true\" style=\"top: 0px; left: 0px; width: 100%; height: 100%; position: absolute;\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0421\u043e\u0431\u044b\u0442\u0438\u044f \u0432 Matreshka.js \u2014 \u044d\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0442\u0435\u043c\u0430. \u041c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 (\u0441\u043b\u0443\u0448\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0433\u043b\u0443\u0431\u0438\u043d\u0435 \u0434\u0435\u0440\u0435\u0432\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432), DOM \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 DOM \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0438 \u043f\u0440. \u0427\u0438\u0442\u0430\u0439\u0442\u0435 <a href=\"https:\/\/habrahabr.ru\/company\/matreshka\/blog\/267513\/\">\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e<\/a> \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443.<\/p>\n<p>  <\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>mediate<\/code> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0440\u0430\u043d\u0442\u0430\u0439\u043c \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0441\u0432\u043e\u0439\u0441\u0442\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u043c\u043e\u0436\u043d\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u043e\u043c, \u043c\u043e\u0436\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e.<\/p>\n<p>  <\/p>\n<pre><code>Matreshka.mediate(object, 'x', x =&gt; String(x)); object.x = 42; console.log(object.x, typeof object.x); \/\/ &quot;42&quot;, &quot;string&quot;<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"klassy\">\u041a\u043b\u0430\u0441\u0441\u044b<\/h1>\n<p>  <\/p>\n<p>\u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u043a\u043b\u0430\u0441\u0441\u0430 <code>Matreshka<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0442\u0435 \u0436\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0435 \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c, \u0441 \u0442\u0435\u043c \u043e\u0442\u043b\u0438\u0447\u0438\u0435\u043c, \u0447\u0442\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u0435\u0440\u0432\u044b\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c: \u0438\u043c \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f <code>this<\/code>.<\/p>\n<p>  <\/p>\n<pre><code>class User extends Matreshka {   constructor() {     super();     this.bindNode('fullName', '.full-name');     this.calc('fullName', ['firstName', 'lastName'], (firstName, lastName) =&gt; {         return `${firstName} ${lastName}`     });     \/\/ chained call can be used there:  super().bindNode(...).calc(...);   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043d\u0438\u0436\u0435 \u043a\u043b\u0430\u0441\u0441\u044b <code>Matreshka.Array<\/code> \u0438 <code>Matreshka.Object<\/code>, \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u044f \u043e\u0431\u0449\u0438\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u044b.<\/p>\n<p>  <\/p>\n<p>\u041a\u043b\u0430\u0441\u0441 <code>Matreshka.Object<\/code> \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0435, \u0442\u0438\u043f\u0430 &quot;\u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435&quot;. \u042d\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0436\u0435\u043b\u0430\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0442 \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0438, \u0441\u043a\u0430\u0436\u0435\u043c, \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0438\u043b\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0443 \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0430 \u0442\u043e, \u043a\u0430\u043a\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0442 \u0437\u0430 \u0431\u0438\u0437\u043d\u0435\u0441 \u043b\u043e\u0433\u0438\u043a\u0443 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f), \u043a\u0430\u043a\u0438\u0435 \u0437\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u0438\u0434\u0435\u043d \u043b\u0438 DOM \u044d\u043b\u0435\u043c\u0435\u043d\u0442). \u0417\u0430 \u044d\u0442\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <code>addDataKeys<\/code>.<\/p>\n<p>  <\/p>\n<pre><code>class User extends Matreshka.Object {   constructor() {     super();     this.firstName = 'Brendan';     this.lastName = 'Eich';     this.language = 'JavaScript';     this.addDataKeys(['firstName', 'lastName']);     console.log(JSON.stringify(this)); \/\/ '{&quot;firstName&quot;: &quot;Brendan&quot;, &quot;lastName&quot;: &quot;Eich&quot;}'   } }<\/code><\/pre>\n<p>  <\/p>\n<p><code>Matreshka.Array<\/code> \u2014 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0432\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0435. \u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b, \u043f\u043e\u043c\u0438\u043c\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0443 <code>Matreshka<\/code>, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u0435\u0442\u043e\u0434\u044b \u0438\u0437 \u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0433\u043e <code>Array<\/code> (<code>push<\/code>, <code>splice<\/code>, <code>map<\/code>, <code>reduce<\/code>&#8230;).<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0439, \u043f\u043e\u0434\u043e\u0431\u043d\u043e Backbone.Collection, \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c &quot;\u043c\u043e\u0434\u0435\u043b\u044c&quot; (\u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>Model<\/code>) \u0441 \u0442\u0435\u043c \u043e\u0442\u043b\u0438\u0447\u0438\u0435\u043c, \u0447\u0442\u043e \u0435\u044e \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0441\u0443\u043f\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u043a\u043b\u0430\u0441\u0441.<\/p>\n<p>  <\/p>\n<pre><code>class Users extends Matreshka.Array {   get Model() { return User; }   constructor() {     super();     this.push({ firstName: 'Brendan', lastName: 'Eich' });     console.log(this[0] instanceof User); \/\/ true   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0443\u0434\u0430 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u043e\u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 DOM \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438 \u043a\u0430\u043a \u0438\u0445 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c. \u0414\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043c\u0435\u0441\u0442\u0430 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430, \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 <code>sandbox<\/code>, \u043b\u0438\u0431\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 <code>container<\/code> (\u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u0441\u043c. \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438) DOM \u0443\u0437\u0435\u043b. \u0414\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043d\u0443\u0436\u043d\u043e \u0432\u043e\u0441\u043c\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c <code>itemRenderer<\/code> (\u043b\u0438\u0431\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c <code>renderer<\/code> \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438).<\/p>\n<p>  <\/p>\n<pre><code>class Foo extends Matreshka.Array {   itemRenderer() {      return '&lt;div&gt;Hello, world!&lt;\/div&gt;';   }   constructor() {     super();     this.bindNode('sandbox', '.sandbox-node');     this.push({}); \/\/ inserts &lt;div&gt;Hello, world!&lt;\/div&gt; to .sandbox-node   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043a\u043b\u0430\u0441\u0441\u0430\u0445 \u0432 \u043f\u043e\u0441\u0442\u0435 <a href=\"https:\/\/habrahabr.ru\/company\/matreshka\/blog\/254889\/\">&quot;\u041e\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043a \u043f\u0440\u043e\u0441\u0442\u043e\u043c\u0443&quot;<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0412\u0441\u0451 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u0432\u044b\u0448\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 CJS\/ES2015 \u043c\u043e\u0434\u0443\u043b\u044f:<\/p>\n<p>  <\/p>\n<pre><code>import calc from 'matreshka\/calc'; import MatreshkaArray from 'matreshka\/array';<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"routing\">\u0420\u043e\u0443\u0442\u0438\u043d\u0433<\/h1>\n<p>  <\/p>\n<p>\u0417\u0430 \u0440\u043e\u0443\u0442\u0438\u043d\u0433 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 <a href=\"https:\/\/github.com\/matreshkajs\/matreshka-router\">matreshka-router<\/a>. \u041e\u043d\u0430 \u0441\u0432\u044f\u0437\u0432\u0430\u0435\u0442 \u0447\u0430\u0441\u0442\u0438 \u0430\u0434\u0440\u0435\u0441\u0430 \u0441\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438:<\/p>\n<p>  <\/p>\n<pre><code>Matreshka.initRouter(object, '\/a\/b\/c\/'); object.a = 'foo'; object.b = 'bar'; object.c = 'baz';  \/\/ makes location.hash to be #!\/foo\/bar\/baz\/<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e <a href=\"https:\/\/habrahabr.ru\/company\/matreshka\/blog\/277171\/\">\u0432 \u0441\u0442\u0430\u0442\u044c\u0435<\/a>.<\/p>\n<p>  <\/p>\n<h1 id=\"vmesto-vyvoda\">\u0412\u043c\u0435\u0441\u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0430<\/h1>\n<p>  <\/p>\n<blockquote><p>Matreshka.js \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043f\u0440\u043e\u043f\u0430\u0441\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u0434\u0436\u0443\u043d\u043e\u043c \u0438 \u0441\u0435\u043d\u044c\u043e\u0440\u043e\u043c, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u043d\u0430 \u0440\u0430\u043d\u043d\u0435\u043c \u044d\u0442\u0430\u043f\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0435 \u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0412\u0441\u0451, \u0447\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u2014 \u044d\u0442\u043e \u0437\u043d\u0430\u043d\u0438\u0435 \u044f\u0437\u044b\u043a\u0430 \u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043f\u043e\u043d\u044f\u0442\u0438\u0439. <\/p><\/blockquote>\n<p>\u0412\u0441\u0435\u043c \u0441\u043f\u0430\u0441\u0438\u0431\u043e.<\/p>\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:\/\/habrahabr.ru\/post\/325480\/\"> https:\/\/habrahabr.ru\/post\/325480\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><a href=\"https:\/\/ru.matreshka.io\/?c\"><img decoding=\"async\" src=\"http:\/\/matreshka.io\/img\/mk5-logo_full-vert.svg\" alt=\"image\"\/><\/a><\/p>\n<p>  <\/p>\n<p>\u041a\u0440\u0430\u0442\u043a\u0438\u0439 \u043e\u0431\u0437\u043e\u0440 Matreshka.js. \u0412 \u043f\u043e\u0441\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f ECMAScript 2017, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 ECMAScript 5.<\/p>\n<p>  <\/p>\n<h1 id=\"osnovnye-funkcii\">\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/h1>\n<p>  <\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>bindNode<\/code> \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<\/p>\n<p>  <\/p>\n<pre><code>const object = { name: 'Brendan' }; const node = document.querySelector('.name'); Matreshka.bindNode(object, 'name', node); object.name = 'Doug';<\/code><\/pre>\n<p>  <\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0px; width: 100%; height: 300px; position: relative;\"><iframe src=\"https:\/\/codepen.io\/finom\/embed\/preview\/oZmGYo?height=300&amp;amp;slug-hash=oZmGYo&amp;amp;default-tabs=js,result&amp;amp;host=http%3A%2F%2Fcodepen.io&amp;amp;embed-version=2\" frameborder=\"0\" allowfullscreen=\"true\" webkitallowfullscreen=\"true\" mozallowfullscreen=\"true\" style=\"top: 0px; left: 0px; width: 100%; height: 100%; position: absolute;\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u0435\u0441\u043b\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u0432\u043e\u0434\u0438\u0442 \u0442\u0435\u043a\u0441\u0442), \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e. \u0418\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438 Matreshka.js \u0443\u043c\u0435\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0444\u043e\u0440\u043c. \u041c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0431\u0430\u0439\u043d\u0434\u0438\u043d\u0433 \u0434\u043b\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 <a href=\"https:\/\/ru.matreshka.io\/#!Matreshka-bindNode\">\u0441\u043c. \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>calc<\/code> \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0434\u043d\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438.<\/p>\n<p>  <\/p>\n<pre><code>Matreshka.calc(object, 'fullName', ['firstName', 'lastName'], (firstName, lastName) =&gt; {     return `${firstName} ${lastName}` }); object.firstName = 'Brendan'; object.lastName = 'Eich'; \/\/ ... console.log(object.fullName); \/\/ &quot;Brendan Eich&quot;<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a (<code>firstName<\/code> \u0438\u043b\u0438 <code>lastName<\/code>), \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e-\u0446\u0435\u043b\u044c (<code>fullName<\/code>).<\/p>\n<p>  <\/p>\n<p>\u0412\u043c\u0435\u0441\u0442\u0435 \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>bindNode<\/code> \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u0434\u043b\u0438\u043d\u043d\u044b\u0435 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439: \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>a<\/code> \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 <code>e1<\/code>, \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>b<\/code> \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>a<\/code>, \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>c<\/code> \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 <code>e2<\/code> \u0438 <code>e3<\/code> \u0438 \u043e\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>b<\/code>, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e, \u043a\u0430\u043a \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435, \u043c\u0435\u043d\u044f\u0435\u0442 <code>e1<\/code>, <code>e2<\/code> \u0438 <code>e3<\/code>&#8230;<\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0435 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Excell): \u0432 \u043a\u0430\u0436\u0434\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b \u0434\u0443\u043c\u0430\u0435\u0442\u0435 \u043e\u0431 \u043e\u0434\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0443\u043b\u0435, \u0430 \u043d\u0435 \u043e \u043c\u043d\u043e\u0433\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0432\u044f\u0437\u044f\u0445 \u0432\u0441\u0435 \u044f\u0447\u0435\u0435\u043a. \u041a\u0430\u043a \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435 \u043c\u0435\u043d\u044c\u0448\u0435 \u0431\u0430\u0433\u043e\u0432, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0443\u0436\u043d\u043e \u0434\u0443\u043c\u0430\u0442\u044c \u043e\u0431 \u0430\u0442\u043e\u043c\u0430\u0440\u043d\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u0445, \u0430 \u043d\u0435 \u043e\u0431\u043e \u0432\u0441\u0435\u0439 &quot;\u0442\u0430\u0431\u043b\u0438\u0446\u0435&quot; (\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438). \u0411\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 <a href=\"https:\/\/ru.matreshka.io\/#!Matreshka-calc\">\u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<p>  <\/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-284330","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/284330","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=284330"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/284330\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=284330"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=284330"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=284330"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}