{"action":"created","comment":{"url":"https://api.github.com/repos/nodejs/node/pulls/comments/50841978","id":50841978,"diff_hunk":"@@ -316,6 +506,90 @@ console.log(bufA.length);\n // 42\n ```\n \n+### Class Method: Buffer.from(str[, encoding])\n+\n+* `str` String - string to encode.\n+* `encoding` String - encoding to use, Optional.\n+\n+Creates a new `Buffer` containing the given JavaScript string `str`. If\n+provided, the `encoding` parameter identifies the strings character encoding.\n+If not provided, `encoding` defaults to `'utf8'`.\n+\n+```js\n+const buf1 = Buffer.from('this is a tést');\n+console.log(buf1.toString());\n+  // prints: this is a tést\n+console.log(buf1.toString('ascii'));\n+  // prints: this is a tC)st\n+\n+const buf2 = Buffer.from('7468697320697320612074c3a97374', 'hex');\n+console.log(buf2.toString());\n+  // prints: this is a tést\n+```\n+\n+A `TypeError` will be thrown if `str` is a number.\n+\n+### Class Method: Buffer.from(array)\n+\n+* `array` Array\n+\n+Allocates a new `Buffer` using an `array` of octets.\n+\n+```js\n+const buf = Buffer.from([0x62,0x75,0x66,0x66,0x65,0x72]);\n+  // creates a new Buffer containing ASCII bytes\n+  // ['b','u','f','f','e','r']\n+```\n+\n+A `TypeError` will be thrown if `array` is a number.\n+\n+### Class Method: Buffer.from(buffer)\n+\n+* `buffer` {Buffer}\n+\n+Copies the passed `buffer` data onto a new `Buffer` instance.\n+\n+```js\n+const buf1 = Buffer.from('buffer');\n+const buf2 = Buffer.from(buf1);\n+\n+buf1[0] = 0x61;\n+console.log(buf1.toString());\n+  // 'auffer'\n+console.log(buf2.toString());\n+  // 'buffer' (copy is not changed)\n+```\n+\n+A `TypeError` will be thrown if `buffer` is a number.\n+\n+### Class Method: Buffer.from(arrayBuffer)\n+\n+* `arrayBuffer` - The `.buffer` property of a `TypedArray` or a `new\n+  ArrayBuffer()`\n+\n+When passed a reference to the `.buffer` property of a `TypedArray` instance,\n+the newly created `Buffer` will share the same allocated memory as the\n+TypedArray.\n+\n+```\n+const arr = new Uint16Array(2);\n+arr[0] = 5000;\n+arr[1] = 4000;\n+\n+const buf = Buffer.from(arr.buffer); // shares the memory with arr;\n+\n+console.log(buf);\n+  // Prints: <Buffer 88 13 a0 0f>\n+\n+// changing the TypedArray changes the Buffer also\n+arr[1] = 6000;\n+\n+console.log(buf);\n+  // Prints: <Buffer 88 13 70 17>\n+```\n+\n+A `TypeError` will be thrown if `arrayBuffer` is a number.\n+","path":"doc/api/buffer.markdown","position":456,"original_position":456,"commit_id":"c03af5cfc12315743d917b6d8dadc6ab7b55ca0c","original_commit_id":"c03af5cfc12315743d917b6d8dadc6ab7b55ca0c","user":{"login":"tflanagan","id":5559820,"avatar_url":"https://avatars.githubusercontent.com/u/5559820?v=3","gravatar_id":"","url":"https://api.github.com/users/tflanagan","html_url":"https://github.com/tflanagan","followers_url":"https://api.github.com/users/tflanagan/followers","following_url":"https://api.github.com/users/tflanagan/following{/other_user}","gists_url":"https://api.github.com/users/tflanagan/gists{/gist_id}","starred_url":"https://api.github.com/users/tflanagan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tflanagan/subscriptions","organizations_url":"https://api.github.com/users/tflanagan/orgs","repos_url":"https://api.github.com/users/tflanagan/repos","events_url":"https://api.github.com/users/tflanagan/events{/privacy}","received_events_url":"https://api.github.com/users/tflanagan/received_events","type":"User","site_admin":false},"body":"I'm totally nit'ing here, but in other areas of the documentation the alphabetical sort extends to the option names as well, so this would be reordered to:\r\n```markdown\r\n### Class Method: Buffer.from(array)\r\n### Class Method: Buffer.from(arrayBuffer)\r\n### Class Method: Buffer.from(buffer)\r\n### Class Method: Buffer.from(str[, encoding])\r\n```\r\n","created_at":"2016-01-26T14:39:00Z","updated_at":"2016-01-26T14:39:00Z","html_url":"https://github.com/nodejs/node/pull/4682#discussion_r50841978","pull_request_url":"https://api.github.com/repos/nodejs/node/pulls/4682","_links":{"self":{"href":"https://api.github.com/repos/nodejs/node/pulls/comments/50841978"},"html":{"href":"https://github.com/nodejs/node/pull/4682#discussion_r50841978"},"pull_request":{"href":"https://api.github.com/repos/nodejs/node/pulls/4682"}}},"pull_request":{"url":"https://api.github.com/repos/nodejs/node/pulls/4682","id":55991304,"html_url":"https://github.com/nodejs/node/pull/4682","diff_url":"https://github.com/nodejs/node/pull/4682.diff","patch_url":"https://github.com/nodejs/node/pull/4682.patch","issue_url":"https://api.github.com/repos/nodejs/node/issues/4682","number":4682,"state":"open","locked":false,"title":"buffer: add Buffer.from(), Buffer.alloc() and Buffer.allocUnsafe(), soft-deprecate Buffer(num)","user":{"login":"jasnell","id":439929,"avatar_url":"https://avatars.githubusercontent.com/u/439929?v=3","gravatar_id":"","url":"https://api.github.com/users/jasnell","html_url":"https://github.com/jasnell","followers_url":"https://api.github.com/users/jasnell/followers","following_url":"https://api.github.com/users/jasnell/following{/other_user}","gists_url":"https://api.github.com/users/jasnell/gists{/gist_id}","starred_url":"https://api.github.com/users/jasnell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasnell/subscriptions","organizations_url":"https://api.github.com/users/jasnell/orgs","repos_url":"https://api.github.com/users/jasnell/repos","events_url":"https://api.github.com/users/jasnell/events{/privacy}","received_events_url":"https://api.github.com/users/jasnell/received_events","type":"User","site_admin":false},"body":"This is currently a work in progress for discussion purposes. Please do not land!\r\n\r\nNode-EPS: https://github.com/nodejs/node-eps/issues/4\r\n\r\nRef: https://github.com/nodejs/node/issues/4660, \r\n\r\nThe purpose of this PR is to ground the discussion in #4660 into concrete terms for discussion purposes only at this point. The PR currently does several things:\r\n\r\n  * It soft deprecates `Buffer()`\r\n  * It adds `Buffer.allocUnsafe(size)` as a direct replacement for `Buffer(number)`\r\n  * It adds `Buffer.alloc(size[, fill])` to create a new initialized Buffer.\r\n  * It adds `Buffer.from(data[, encoding)` as a direct replacement for `Buffer(data[, encoding])` (for every variant)\r\n  * It adds a `--zero-fill-buffers` command line flag that forces `Buffer(number)`, `Buffer.alloc()`, and `SlowBuffer(number)` to zero fill the initialized Buffers.\r\n  * The argument checking for `Buffer.alloc(size[, fill])` and `Buffer.allocUnsafe(size)` is such that only non-negative number values are permitted for the size and `fill` must be a string.\r\n  * It adds documentation, test cases and new benchmarks for each of these.\r\n  * It modifies every existing call to `Buffer()` currently in core in order to demonstrate the extent of the changes required by these edits. It's not a small change by any measure.\r\n\r\nNote: PR description updated to reflect new naming and implementation details","created_at":"2016-01-14T04:23:32Z","updated_at":"2016-01-26T14:39:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"92757567c935bba0bd7192392f2ca4c280316a32","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/nodejs/node/pulls/4682/commits","review_comments_url":"https://api.github.com/repos/nodejs/node/pulls/4682/comments","review_comment_url":"https://api.github.com/repos/nodejs/node/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nodejs/node/issues/4682/comments","statuses_url":"https://api.github.com/repos/nodejs/node/statuses/c03af5cfc12315743d917b6d8dadc6ab7b55ca0c","head":{"label":"jasnell:buffer-safe","ref":"buffer-safe","sha":"c03af5cfc12315743d917b6d8dadc6ab7b55ca0c","user":{"login":"jasnell","id":439929,"avatar_url":"https://avatars.githubusercontent.com/u/439929?v=3","gravatar_id":"","url":"https://api.github.com/users/jasnell","html_url":"https://github.com/jasnell","followers_url":"https://api.github.com/users/jasnell/followers","following_url":"https://api.github.com/users/jasnell/following{/other_user}","gists_url":"https://api.github.com/users/jasnell/gists{/gist_id}","starred_url":"https://api.github.com/users/jasnell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasnell/subscriptions","organizations_url":"https://api.github.com/users/jasnell/orgs","repos_url":"https://api.github.com/users/jasnell/repos","events_url":"https://api.github.com/users/jasnell/events{/privacy}","received_events_url":"https://api.github.com/users/jasnell/received_events","type":"User","site_admin":false},"repo":{"id":37868459,"name":"node","full_name":"jasnell/node","owner":{"login":"jasnell","id":439929,"avatar_url":"https://avatars.githubusercontent.com/u/439929?v=3","gravatar_id":"","url":"https://api.github.com/users/jasnell","html_url":"https://github.com/jasnell","followers_url":"https://api.github.com/users/jasnell/followers","following_url":"https://api.github.com/users/jasnell/following{/other_user}","gists_url":"https://api.github.com/users/jasnell/gists{/gist_id}","starred_url":"https://api.github.com/users/jasnell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasnell/subscriptions","organizations_url":"https://api.github.com/users/jasnell/orgs","repos_url":"https://api.github.com/users/jasnell/repos","events_url":"https://api.github.com/users/jasnell/events{/privacy}","received_events_url":"https://api.github.com/users/jasnell/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jasnell/node","description":"Future Node.js releases will be based on io.js","fork":true,"url":"https://api.github.com/repos/jasnell/node","forks_url":"https://api.github.com/repos/jasnell/node/forks","keys_url":"https://api.github.com/repos/jasnell/node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jasnell/node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jasnell/node/teams","hooks_url":"https://api.github.com/repos/jasnell/node/hooks","issue_events_url":"https://api.github.com/repos/jasnell/node/issues/events{/number}","events_url":"https://api.github.com/repos/jasnell/node/events","assignees_url":"https://api.github.com/repos/jasnell/node/assignees{/user}","branches_url":"https://api.github.com/repos/jasnell/node/branches{/branch}","tags_url":"https://api.github.com/repos/jasnell/node/tags","blobs_url":"https://api.github.com/repos/jasnell/node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jasnell/node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jasnell/node/git/refs{/sha}","trees_url":"https://api.github.com/repos/jasnell/node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jasnell/node/statuses/{sha}","languages_url":"https://api.github.com/repos/jasnell/node/languages","stargazers_url":"https://api.github.com/repos/jasnell/node/stargazers","contributors_url":"https://api.github.com/repos/jasnell/node/contributors","subscribers_url":"https://api.github.com/repos/jasnell/node/subscribers","subscription_url":"https://api.github.com/repos/jasnell/node/subscription","commits_url":"https://api.github.com/repos/jasnell/node/commits{/sha}","git_commits_url":"https://api.github.com/repos/jasnell/node/git/commits{/sha}","comments_url":"https://api.github.com/repos/jasnell/node/comments{/number}","issue_comment_url":"https://api.github.com/repos/jasnell/node/issues/comments{/number}","contents_url":"https://api.github.com/repos/jasnell/node/contents/{+path}","compare_url":"https://api.github.com/repos/jasnell/node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jasnell/node/merges","archive_url":"https://api.github.com/repos/jasnell/node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jasnell/node/downloads","issues_url":"https://api.github.com/repos/jasnell/node/issues{/number}","pulls_url":"https://api.github.com/repos/jasnell/node/pulls{/number}","milestones_url":"https://api.github.com/repos/jasnell/node/milestones{/number}","notifications_url":"https://api.github.com/repos/jasnell/node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jasnell/node/labels{/name}","releases_url":"https://api.github.com/repos/jasnell/node/releases{/id}","deployments_url":"https://api.github.com/repos/jasnell/node/deployments","created_at":"2015-06-22T17:01:18Z","updated_at":"2016-01-11T18:47:43Z","pushed_at":"2016-01-26T03:47:53Z","git_url":"git://github.com/jasnell/node.git","ssh_url":"git@github.com:jasnell/node.git","clone_url":"https://github.com/jasnell/node.git","svn_url":"https://github.com/jasnell/node","homepage":"https://iojs.org","size":169056,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"nodejs:master","ref":"master","sha":"0f8e63caffb8d7c9ff1d2baef7b657db77525ddb","user":{"login":"nodejs","id":9950313,"avatar_url":"https://avatars.githubusercontent.com/u/9950313?v=3","gravatar_id":"","url":"https://api.github.com/users/nodejs","html_url":"https://github.com/nodejs","followers_url":"https://api.github.com/users/nodejs/followers","following_url":"https://api.github.com/users/nodejs/following{/other_user}","gists_url":"https://api.github.com/users/nodejs/gists{/gist_id}","starred_url":"https://api.github.com/users/nodejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodejs/subscriptions","organizations_url":"https://api.github.com/users/nodejs/orgs","repos_url":"https://api.github.com/users/nodejs/repos","events_url":"https://api.github.com/users/nodejs/events{/privacy}","received_events_url":"https://api.github.com/users/nodejs/received_events","type":"Organization","site_admin":false},"repo":{"id":27193779,"name":"node","full_name":"nodejs/node","owner":{"login":"nodejs","id":9950313,"avatar_url":"https://avatars.githubusercontent.com/u/9950313?v=3","gravatar_id":"","url":"https://api.github.com/users/nodejs","html_url":"https://github.com/nodejs","followers_url":"https://api.github.com/users/nodejs/followers","following_url":"https://api.github.com/users/nodejs/following{/other_user}","gists_url":"https://api.github.com/users/nodejs/gists{/gist_id}","starred_url":"https://api.github.com/users/nodejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodejs/subscriptions","organizations_url":"https://api.github.com/users/nodejs/orgs","repos_url":"https://api.github.com/users/nodejs/repos","events_url":"https://api.github.com/users/nodejs/events{/privacy}","received_events_url":"https://api.github.com/users/nodejs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nodejs/node","description":"Node.js JavaScript runtime :sparkles::turtle::rocket::sparkles:","fork":false,"url":"https://api.github.com/repos/nodejs/node","forks_url":"https://api.github.com/repos/nodejs/node/forks","keys_url":"https://api.github.com/repos/nodejs/node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nodejs/node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nodejs/node/teams","hooks_url":"https://api.github.com/repos/nodejs/node/hooks","issue_events_url":"https://api.github.com/repos/nodejs/node/issues/events{/number}","events_url":"https://api.github.com/repos/nodejs/node/events","assignees_url":"https://api.github.com/repos/nodejs/node/assignees{/user}","branches_url":"https://api.github.com/repos/nodejs/node/branches{/branch}","tags_url":"https://api.github.com/repos/nodejs/node/tags","blobs_url":"https://api.github.com/repos/nodejs/node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nodejs/node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nodejs/node/git/refs{/sha}","trees_url":"https://api.github.com/repos/nodejs/node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nodejs/node/statuses/{sha}","languages_url":"https://api.github.com/repos/nodejs/node/languages","stargazers_url":"https://api.github.com/repos/nodejs/node/stargazers","contributors_url":"https://api.github.com/repos/nodejs/node/contributors","subscribers_url":"https://api.github.com/repos/nodejs/node/subscribers","subscription_url":"https://api.github.com/repos/nodejs/node/subscription","commits_url":"https://api.github.com/repos/nodejs/node/commits{/sha}","git_commits_url":"https://api.github.com/repos/nodejs/node/git/commits{/sha}","comments_url":"https://api.github.com/repos/nodejs/node/comments{/number}","issue_comment_url":"https://api.github.com/repos/nodejs/node/issues/comments{/number}","contents_url":"https://api.github.com/repos/nodejs/node/contents/{+path}","compare_url":"https://api.github.com/repos/nodejs/node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nodejs/node/merges","archive_url":"https://api.github.com/repos/nodejs/node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nodejs/node/downloads","issues_url":"https://api.github.com/repos/nodejs/node/issues{/number}","pulls_url":"https://api.github.com/repos/nodejs/node/pulls{/number}","milestones_url":"https://api.github.com/repos/nodejs/node/milestones{/number}","notifications_url":"https://api.github.com/repos/nodejs/node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nodejs/node/labels{/name}","releases_url":"https://api.github.com/repos/nodejs/node/releases{/id}","deployments_url":"https://api.github.com/repos/nodejs/node/deployments","created_at":"2014-11-26T19:57:11Z","updated_at":"2016-01-26T13:29:08Z","pushed_at":"2016-01-26T14:20:51Z","git_url":"git://github.com/nodejs/node.git","ssh_url":"git@github.com:nodejs/node.git","clone_url":"https://github.com/nodejs/node.git","svn_url":"https://github.com/nodejs/node","homepage":"https://nodejs.org","size":202764,"stargazers_count":19657,"watchers_count":19657,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2378,"mirror_url":null,"open_issues_count":697,"forks":2378,"open_issues":697,"watchers":19657,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nodejs/node/pulls/4682"},"html":{"href":"https://github.com/nodejs/node/pull/4682"},"issue":{"href":"https://api.github.com/repos/nodejs/node/issues/4682"},"comments":{"href":"https://api.github.com/repos/nodejs/node/issues/4682/comments"},"review_comments":{"href":"https://api.github.com/repos/nodejs/node/pulls/4682/comments"},"review_comment":{"href":"https://api.github.com/repos/nodejs/node/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nodejs/node/pulls/4682/commits"},"statuses":{"href":"https://api.github.com/repos/nodejs/node/statuses/c03af5cfc12315743d917b6d8dadc6ab7b55ca0c"}}}}