{"id":279283,"date":"2016-04-28T15:20:07","date_gmt":"2016-04-28T11:20:07","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=279283"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=279283","title":{"rendered":"\u0412\u044b\u0448\u0435\u043b \u0432 \u0441\u0432\u0435\u0442 Node.JS v6.0"},"content":{"rendered":"\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0443\u0432\u0438\u0434\u0435\u043b\u0430 \u0441\u0432\u0435\u0442 \u0432\u0435\u0440\u0441\u0438\u044f 6.0. \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043c\u043d\u043e\u0433\u043e, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0437\u0430 \u0441\u0447\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0435\u0440\u0441\u0438\u0438 v8 (\u0434\u043e v5.0), \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043b\u043e\u043c\u0430\u0442\u044c \u0432\u0430\u0448 \u043a\u043e\u0434. \u041e \u0442\u043e\u043c \u043a\u0430\u043a\u0438\u0435 \u043d\u043e\u0432\u043e\u0432\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0432\u0430\u0441 \u0436\u0434\u0443\u0442, \u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u043f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h2>\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f API<\/h2>\n<p>  <\/p>\n<p>\u0412\u044b\u0434\u0435\u0440\u0436\u043a\u0430 \u0438\u0437 changelog \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439:<\/p>\n<p>  <\/p>\n<h3>Buffer<\/h3>\n<p>  <\/p>\n<p>\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 Buffer \u0438\u0437\u043c\u0435\u043d\u0438\u043b \u0441\u0432\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435. \u0421\u0442\u0430\u0440\u044b\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0441\u0442\u0430\u0442\u0443\u0441 deprecated, \u0430 \u0435\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0448\u043b\u043e \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ \u0411\u044b\u043b\u043e new Buffer(size);  \/\/ \u0421\u0442\u0430\u043b\u043e Buffer.alloc(size);<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0431\u0443\u0444\u0435\u0440 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0443\u043b\u044f\u043c\u0438, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>Buffer.allocUnsafe<\/code>. \u0414\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u0443\u0444\u0435\u0440\u0430 \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0431\u0443\u0444\u0435\u0440\u043e\u0432 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <code>Buffer.from<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ \u0411\u044b\u043b\u043e new Buffer(str, 'utf8');  \/\/ \u0421\u0442\u0430\u043b\u043e Buffer.from(str, 'utf8');<\/code><\/pre>\n<p>  <\/p>\n<h2>EventEmitter<\/h2>\n<p>  <\/p>\n<p>\u041e\u0431\u044a\u0435\u043a\u0442 EventEmitter \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0434\u0432\u0430 \u043d\u043e\u0432\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0430 <code>prependListener<\/code> \u0438 <code>prependOnceListener<\/code>, \u043e\u0431\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442 \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0441\u043e\u0431\u044b\u0442\u0438\u044f.<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">var ee = new EventEmitter();  var result = []; ee.on('event', () =&gt; result.push(1)); ee.prependListener('event', () =&gt; result.push(2)); ee.emit('event');  result; \/\/ -&gt; [2, 1]<\/code><\/pre>\n<p>  <\/p>\n<h2>FileSystem<\/h2>\n<p>  <\/p>\n<p>\u041c\u0435\u0442\u043e\u0434\u044b <code>fs.realpath<\/code> \u0438 <code>fs.realpathSync<\/code> \u0442\u0435\u043f\u0435\u0440\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 libuv \u0438 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438. \u0422\u0430\u043a \u0436\u0435 \u043d\u0430 \u0432\u0445\u043e\u0434 \u044d\u0442\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u0430\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0430\u0432\u0430\u0442\u044c Buffer.<\/p>\n<p>  <\/p>\n<h2>HTTP<\/h2>\n<p>  <\/p>\n<p>HTTP-\u0441\u0435\u0440\u0432\u0435\u0440 \u0442\u0435\u043f\u0435\u0440\u044c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 clientError \u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u0430. \u041f\u0440\u0438\u043c\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c <a href=\"https:\/\/github.com\/nodejs\/node\/issues\/4543\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>  <\/p>\n<h2>Process<\/h2>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f \u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u0445. \u0412\u043c\u0435\u0441\u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 stderr, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f \u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">process.emitWarning('something goes wrong');<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 \u0432 \u043d\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 <code>Error<\/code>. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 <a href=\"https:\/\/nodejs.org\/dist\/latest-v6.x\/docs\/api\/process.html#process_process_emitwarning_warning_name_ctor\">\u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<p>  <\/p>\n<h2>Stream<\/h2>\n<p>  <\/p>\n<p>\u041f\u043e\u0442\u043e\u043a\u0438 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0441\u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c <code>null<\/code>.<\/p>\n<p>  <\/p>\n<h2>URL<\/h2>\n<p>  <\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>url.resolve<\/code> \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f username \u0438 password \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0445\u043e\u0441\u0442\u0430.<\/p>\n<p>  <\/p>\n<h2>Windows<\/h2>\n<p>  <\/p>\n<p>\u041e\u0442\u043a\u0430\u0437 \u043e\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 WinXP \u0438 Vista.<\/p>\n<p>  <\/p>\n<h1>\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f v8<\/h1>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432 node.js \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043a\u0440\u0443\u0442\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0438\u0437 JS 2016!<\/p>\n<p>  <\/p>\n<h2>\u0414\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u0435<\/h2>\n<p>  <\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0438\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u0440\u044f\u043c\u0438\u043a\u043e\u043c \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">let [a, b] = [1, 2]; let {c, e} = {c: 3, e: 4};<\/code><\/pre>\n<p>  <\/p>\n<h2>\u0414\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/h2>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u043b\u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u043c\u043e\u0436\u043d\u043e \u0438 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function fn({arg}) {     return arg; }  fn({arg: '1'}); \/\/ -&gt; 1<\/code><\/pre>\n<p>  <\/p>\n<h2>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/h2>\n<p>  <\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u043b\u0438\u0448\u043d\u0438\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0442\u0435\u043b\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"javascript\">function doSomething(task = 'nothing') {     console.log('I\\'m gonna do %s.', task); }  doSomething(); \/\/ -&gt; I'm gonna do nothing.<\/code><\/pre>\n<p>  <\/p>\n<h2>Proxy \u0438 Reflect<\/h2>\n<p>  <\/p>\n<p>\u041e\u0431\u044a\u0435\u043a\u0442\u044b Proxy \u0438 Reflect \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0431\u0435\u0437 \u0444\u043b\u0430\u0433\u043e\u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n<p>  <\/p>\n<h2>\u041d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0442 Array<\/h2>\n<p>  <\/p>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e <em>\u043f\u043e\u0447\u0442\u0438<\/em> \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>Array<\/code>.<\/p>\n<p>  <\/p>\n<h1>P.S.<\/h1>\n<p>  <\/p>\n<p>\u041f\u043e-\u043c\u043e\u0435\u043c\u0443, \u043e\u0447\u0435\u043d\u044c \u043a\u0440\u0443\u0442\u043e\u0439 \u0440\u0435\u043b\u0438\u0437 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0432 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437! \u0414\u0443\u043c\u0430\u044e, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0437\u0434\u0440\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 node.js.<\/p>\n<div class=\"clear\"><\/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:\/\/habrahabr.ru\/post\/282688\/\"> https:\/\/habrahabr.ru\/post\/282688\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0443\u0432\u0438\u0434\u0435\u043b\u0430 \u0441\u0432\u0435\u0442 \u0432\u0435\u0440\u0441\u0438\u044f 6.0. \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043c\u043d\u043e\u0433\u043e, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0437\u0430 \u0441\u0447\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0435\u0440\u0441\u0438\u0438 v8 (\u0434\u043e v5.0), \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043b\u043e\u043c\u0430\u0442\u044c \u0432\u0430\u0448 \u043a\u043e\u0434. \u041e \u0442\u043e\u043c \u043a\u0430\u043a\u0438\u0435 \u043d\u043e\u0432\u043e\u0432\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0432\u0430\u0441 \u0436\u0434\u0443\u0442, \u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u043f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c.<\/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-279283","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/279283","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=279283"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/279283\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=279283"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=279283"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=279283"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}