Example on README doesn't show that the yield loadAs returns an array

Open
#131 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
30/100
Issue type
Documentation
Clarity
Needs clarification
Activity status
Stale
Tech stack
javascript
Domain
documentation

Research direction

Start with the README example using repo.loadAs("commit", commitHash) and repo.loadAs("tree", commit.tree). Inspect the loadAs behavior to determine why the result contains an object and an undefined second element, then clarify the example and explain the second value if the behavior is intentional. Verify that the README accurately describes the returned value.

Written by the indexing model from the issue text.

Description

bug Documentation

Is the README example correct?

For example it says:

var commit = yield repo.loadAs("commit", commitHash);
var tree = yield repo.loadAs("tree", commit.tree);

But when I tried this, the commit was an array with the first element being an object containing tree, while the second element was just undefined.

I end up using the destructuring syntax let [commit] = ... to get around this, but what is the second element for? Even when I pass in a garbage commit hash, it's undefined (at first I thought it might be a [val, err] pattern).

Dominant language
JavaScript
Stars
3.8k
Forks
262
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from creationix/js-git

All issues in creationix/js-git

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.