<commit_before># hypercore-archiver

Easily archive multiple hypercores or hyperdrives

## Usage

``` js
var archiver = require('hypercore-archiver')
var hypercore = require('hypercore')

var ar = archiver('./my-archiver') // also supports passing in a storage provider
var feed = hypercore('./my-feed')

feed.on('ready', function () {
  ar.add(feed.key, function (err) {
    console.log('will now archive the feed')
  })
})

ar.on('sync', function (feed) {
  console.log('feed is synced', feed.key)
})

// setup replication
var stream = ar.replicate()
stream.pipe(feed.replicate({live: true})).pipe(stream)

feed.append(['hello', 'world'])
```

## API

#### `var ar = archiver(storage, [key], [options])`

Create a new archvier. `storage` can be a file system path or a storage provider like [random-access-memory](https://github.com/mafintosh/random-access-memory).

If this archiver is a clone of another archiver pass the changes feed key as the 2nd argument.

Options include

``` js
{
  sparse: false // set to true to only archive blocks you request
}
```

##### Sparse File Storage

The sparse option uses sparse file mode, only availalbe on some file systems. It will appear as a full size file but only take up the space actually used on disk.

* Use `ls -alsh` to view the actual size (first column)
* sparse file mode (APFS) is not available on Mac OSX.

#### `ar.add(key, [callback])`

Add a new hypercore or hyperdrive key to be archived.<commit_msg>Fix typo<commit_after># hypercore-archiver

Easily archive multiple hypercores or hyperdrives

## Usage

``` js
var archiver = require('hypercore-archiver')
var hypercore = require('hypercore')

var ar = archiver('./my-archiver') // also supports passing in a storage provider
var feed = hypercore('./my-feed')

feed.on('ready', function () {
  ar.add(feed.key, function (err) {
    console.log('will now archive the feed')
  })
})

ar.on('sync', function (feed) {
  console.log('feed is synced', feed.key)
})

// setup replication
var stream = ar.replicate()
stream.pipe(feed.replicate({live: true})).pipe(stream)

feed.append(['hello', 'world'])
```

## API

#### `var ar = archiver(storage, [key], [options])`

Create a new archvier. `storage` can be a file system path or a storage provider like [random-access-memory](https://github.com/mafintosh/random-access-memory).

If this archiver is a clone of another archiver pass the changes feed key as the 2nd argument.

Options include

``` js
{
  sparse: false // set to true to only archive blocks you request
}
```

##### Sparse File Storage

The sparse option uses sparse file mode, only available on some file systems. It will appear as a full size file but only take up the space actually used on disk.

* Use `ls -alsh` to view the actual size (first column)
* sparse file mode (APFS) is not available on Mac OSX.

#### `ar.add(key, [callback])`

Add a new hypercore or hyperdrive key to be archived.
{'fraction_non_alphanumeric': 0.12931919261033184, 'fraction_numerical': 0.0006842285323297981, 'mean_word_length': 4.2214285714285715, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '4565007', 'n_tokens_mistral': 913, 'n_tokens_neox': 885, 'n_words': 352}