<commit_before># Repo API

* [repo.gc](#repogc)
* [repo.stat](#repostat)
* [repo.version](#repoversion)

#### `repo.gc`

> Perform a garbage collection sweep on the repo.

##### `ipfs.repo.gc([options], [callback])`

Where:

- `options` is an object that contains following properties
  - `quiet` writes a minimal output.
  - `stream-errors` stream errors.

`callback` must follow `function (err, res) {}` signature, where `err` is an Error if the operation was not successful.

If no `callback` is passed, a promise is returned.

**Example:**

```JavaScript
ipfs.repo.gc((err, res) => console.log(res))
```

#### `repo.stat`

> Get stats for the currently used repo.

##### `ipfs.repo.stat([options], [callback])`

`stats.repo` and `repo.stat` can be used interchangeably.

Where:

- `options` is an object that contains following properties
  - `human` a Boolean value to output `repoSize` in MiB.

`callback` must follow `function (err, stats) {}` signature, where `err` is an Error if the operation was not successful and `stats` is an object containing the following keys:

- `numObjects` is a [BigNumber Int][1].
- `repoSize` is a [BigNumber Int][1], in bytes.
- `repoPath` is a string.
- `version` is a string.
- `storageMax` is a [BigNumber Int][1].

If no `callback` is passed, a promise is returned.

**Example:**

```JavaScript
ipfs.repo.stat((err, stats) => console.log(stats))

// { numObjects: 15,
//   repoSize: 64190,
//   repoPath: 'C:\\Users\\henri\\AppData\\Local\\Temp\\ipfs_687c6eb3da07d3b16fe3c63ce17560e9',
//   version: 'fs-repo@6',
//   storageMax: 10000000000 }
```

#### `repo.version`

> Show the repo version.

##### `ipfs.repo.version([callback])`

`callback` must follow `function (err, version) {}` signature, where `err` is an Error if the operation was not successful and `version` is a String containing the version.

If no `callback` is passed, a promise is returned.

**Example:**

```JavaScript
ipfs.repo.version((err, version) => console.log(version))

// "6"
```

[1]: https://github.com/MikeMcl/bignumber.js/<commit_msg>fix: repo.gc() response format (#492)<commit_after># Repo API

* [repo.gc](#repogc)
* [repo.stat](#repostat)
* [repo.version](#repoversion)

#### `repo.gc`

> Perform a garbage collection sweep on the repo.

##### `ipfs.repo.gc([options], [callback])`

Where:

- `options` is an object that contains following properties
  - `quiet` writes a minimal output.
  - `stream-errors` stream errors.

`callback` must follow `function (err, res) {}` signature, where
- `err` is an Error if the whole GC operation was not successful.
- `res` is an array of objects that contains the following properties
  - `err` is an Error if it was not possible to GC a particular block.
  - `cid` is the [CID][cid] of the block that was Garbage Collected.

If no `callback` is passed, a promise is returned.

**Example:**

```JavaScript
ipfs.repo.gc((err, res) => console.log(res))
```

#### `repo.stat`

> Get stats for the currently used repo.

##### `ipfs.repo.stat([options], [callback])`

`stats.repo` and `repo.stat` can be used interchangeably.

Where:

- `options` is an object that contains following properties
  - `human` a Boolean value to output `repoSize` in MiB.

`callback` must follow `function (err, stats) {}` signature, where `err` is an Error if the operation was not successful and `stats` is an object containing the following keys:

- `numObjects` is a [BigNumber Int][1].
- `repoSize` is a [BigNumber Int][1], in bytes.
- `repoPath` is a string.
- `version` is a string.
- `storageMax` is a [BigNumber Int][1].

If no `callback` is passed, a promise is returned.

**Example:**

```JavaScript
ipfs.repo.stat((err, stats) => console.log(stats))

// { numObjects: 15,
//   repoSize: 64190,
//   repoPath: 'C:\\Users\\henri\\AppData\\Local\\Temp\\ipfs_687c6eb3da07d3b16fe3c63ce17560e9',
//   version: 'fs-repo@6',
//   storageMax: 10000000000 }
```

#### `repo.version`

> Show the repo version.

##### `ipfs.repo.version([callback])`

`callback` must follow `function (err, version) {}` signature, where `err` is an Error if the operation was not successful and `version` is a String containing the version.

If no `callback` is passed, a promise is returned.

**Example:**

```JavaScript
ipfs.repo.version((err, version) => console.log(version))

// "6"
```

[1]: https://github.com/MikeMcl/bignumber.js/
[cid]: https://www.npmjs.com/package/cids
{'fraction_non_alphanumeric': 0.16126105692900886, 'fraction_numerical': 0.020185983216148787, 'mean_word_length': 4.188235294117647, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 3, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6219170', 'n_tokens_mistral': 1529, 'n_tokens_neox': 1441, 'n_words': 495}