Title: Return promises instead of nesting them · Issue #407 · nodegit/nodegit · GitHub
Open Graph Title: Return promises instead of nesting them · Issue #407 · nodegit/nodegit
X Title: Return promises instead of nesting them · Issue #407 · nodegit/nodegit
Description: The first example on the documentation reproduces callback hell which promises actually are supposed to prevent =D. Instead of: var clone = require("nodegit").Clone.clone; // Clone a given repository into a tmp folder. clone("git://githu...
Open Graph Description: The first example on the documentation reproduces callback hell which promises actually are supposed to prevent =D. Instead of: var clone = require("nodegit").Clone.clone; // Clone a given reposito...
X Description: The first example on the documentation reproduces callback hell which promises actually are supposed to prevent =D. Instead of: var clone = require("nodegit").Clone.clone; // Clone a give...
Opengraph URL: https://github.com/nodegit/nodegit/issues/407
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Return promises instead of nesting them","articleBody":"The first example on the documentation reproduces callback hell which promises actually are supposed to prevent =D.\n\nInstead of:\n\n``` javascript\nvar clone = require(\"nodegit\").Clone.clone;\n\n// Clone a given repository into a tmp folder.\nclone(\"git://github.com/nodegit/nodegit\", \"tmp\").then(function(repo) {\n // Use a known commit sha from this repository.\n var sha = \"59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5\";\n\n // Look up this known commit.\n repo.getCommit(sha).then(function(commit) {\n // Look up a specific file within that commit.\n commit.getEntry(\"README.md\").then(function(entry) {\n // Get the blob contents from the file.\n entry.getBlob().then(function(blob) {\n // Show the name, sha, and filesize in byes.\n console.log(entry.filename(), entry.sha(), blob.rawsize());\n\n // Show a spacer.\n console.log(Array(72).join(\"=\") + \"\\n\\n\");\n\n // Show the entire file.\n console.log(String(blob));\n });\n });\n });\n});\n```\n\nyou should write\n\n``` javascript\nvar clone = require(\"nodegit\").Clone.clone;\n\n// Clone a given repository into a tmp folder.\nclone(\"git://github.com/nodegit/nodegit\", \"tmp\")\n .then(function(repo) {\n // Use a known commit sha from this repository.\n var sha = \"59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5\";\n\n // Look up this known commit.\n return repo.getCommit(sha)\n })\n .then(function(commit) {\n // Look up a specific file within that commit.\n return commit.getEntry(\"README.md\")\n })\n .then(function(entry) {\n // Get the blob contents from the file.\n return entry.getBlob()\n })\n .then(function(blob) {\n // Show the name, sha, and filesize in byes.\n console.log(entry.filename(), entry.sha(), blob.rawsize());\n\n // Show a spacer.\n console.log(Array(72).join(\"=\") + \"\\n\\n\");\n\n // Show the entire file.\n console.log(String(blob));\n });\n```\n","author":{"url":"https://github.com/adius","@type":"Person","name":"adius"},"datePublished":"2015-02-15T17:55:59.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/407/nodegit/issues/407"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:fd745a30-6087-0dd8-1950-26aebd24da2c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ABA4:26FD39:16031AC:1D9DCAA:6A5D2616 |
| html-safe-nonce | d2515346c96e8dcc35e8cad8386b9535e27dcd4f195c0e30dbeef8479dc003e1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQkE0OjI2RkQzOToxNjAzMUFDOjFEOURDQUE6NkE1RDI2MTYiLCJ2aXNpdG9yX2lkIjoiODcyODYxNjkzMTY5ODc0NjkwMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ded62f098bcf4c2d86fd75233e298cdc06760bf5bf10f0bdb9227b096e2ed8ac |
| hovercard-subject-tag | issue:57738910 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodegit/nodegit/407/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a475f95761367593cc994fbde42dcadf0b8f4e744d4b6519e53955d9ca912722/nodegit/nodegit/issues/407 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a475f95761367593cc994fbde42dcadf0b8f4e744d4b6519e53955d9ca912722/nodegit/nodegit/issues/407 |
| og:image:alt | The first example on the documentation reproduces callback hell which promises actually are supposed to prevent =D. Instead of: var clone = require("nodegit").Clone.clone; // Clone a given reposito... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | adius |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| turbo-cache-control | no-preview |
| go-import | github.com/nodegit/nodegit git https://github.com/nodegit/nodegit.git |
| octolytics-dimension-user_id | 657068 |
| octolytics-dimension-user_login | nodegit |
| octolytics-dimension-repository_id | 1383170 |
| octolytics-dimension-repository_nwo | nodegit/nodegit |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1383170 |
| octolytics-dimension-repository_network_root_nwo | nodegit/nodegit |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width