mirror of
https://github.com/aljazceru/pear-docs.git
synced 2025-12-18 06:54:22 +01:00
voice
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
A series of binary encoders/decoders for building small and fast parsers and serializers.
|
||||
|
||||
> [Github (Compact-Encoding)](https://github.com/compact-encoding/compact-encoding)
|
||||
> [GitHub (Compact-Encoding)](https://github.com/compact-encoding/compact-encoding)
|
||||
|
||||
* [Compact-Encoding](compact-encoding.md#installation)
|
||||
* Methods
|
||||
@@ -43,7 +43,7 @@ const state = cenc.state()
|
||||
|
||||
#### **`enc.preencode(state, val)`**
|
||||
|
||||
Performs a fast preencode dry-run that only sets `state.end`. Use this to figure out how big of a buffer you need.
|
||||
Performs a fast preencode dry-run that only sets `state.end`. Use this to figure out how big the buffer needs to be.
|
||||
|
||||
```javascript
|
||||
const cenc = require('compact-encoding')
|
||||
@@ -84,7 +84,7 @@ cenc.string.decode(state) // 'hi'
|
||||
|
||||
### Helpers
|
||||
|
||||
To encode to a buffer or decode from one, use the `encode` and `decode` helpers to reduce your boilerplate.
|
||||
To encode to a buffer or decode from one, use the `encode` and `decode` helpers to reduce boilerplate.
|
||||
|
||||
```javascript
|
||||
const buf = cenc.encode(cenc.bool, true)
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
<mark style="background-color:green;">**stable**</mark>
|
||||
|
||||
Corestore is a Hypercore factory that makes it easier to manage large collections of named Hypercores. It is designed to efficiently store and replicate multiple sets of interlinked [hypercore.md](../building-blocks/hypercore.md "mention")(s), such as those used by [hyperdrive.md](../building-blocks/hyperdrive.md "mention"), removing the responsibility of managing custom storage/replication code from these higher-level modules.
|
||||
Corestore is a Hypercore factory that makes it easier to manage large collections of named Hypercores. It is designed to efficiently store and replicate multiple sets of interlinked [hypercore.md](../building-blocks/hypercore.md)(s), such as those used by [hyperdrive.md](../building-blocks/hyperdrive.md), removing the responsibility of managing custom storage/replication code from these higher-level modules.
|
||||
|
||||
> [Github (Corestore)](https://github.com/holepunchto/corestore)
|
||||
> [GitHub (Corestore)](https://github.com/holepunchto/corestore)
|
||||
|
||||
* [Corestore](corestore.md#installation)
|
||||
* [Create a new instance](corestore.md#const-store--new-corestorestorage-options)
|
||||
@@ -68,7 +68,7 @@ const core4 = store.get({ key: otherKey })
|
||||
const core5 = store.get(otherKey)
|
||||
```
|
||||
|
||||
> The names you provide are only relevant **locally**, in that they are used to deterministically generate key pairs. Whenever you load a core by name, that core will be writable. Names are not shared with remote peers.
|
||||
> The names provided are only relevant **locally**, in that they are used to deterministically generate key pairs. Whenever a core is loaded by name, that core will be writable. Names are not shared with remote peers.
|
||||
|
||||
#### **`const stream = store.replicate(options|stream)`**
|
||||
|
||||
@@ -80,7 +80,7 @@ Corestore replicates in an 'all-to-all' fashion, meaning that when replication b
|
||||
|
||||
If the remote side dynamically adds a new Hypercore to the replication stream (by opening that core with a `get` on their Corestore, for example), Corestore will load and replicate that core if possible.
|
||||
|
||||
Using [hyperswarm.md](../building-blocks/hyperswarm.md "mention") one can replicate Corestores as follows:
|
||||
Using [hyperswarm.md](../building-blocks/hyperswarm.md) one can replicate Corestores as follows:
|
||||
|
||||
```javascript
|
||||
const swarm = new Hyperswarm()
|
||||
@@ -112,7 +112,7 @@ const core1 = ns1.get({ name: 'main' }) // These will load different Hypercores
|
||||
const core2 = ns2.get({ name: 'main' })
|
||||
```
|
||||
|
||||
Namespacing is particularly useful if your application needs to create many different data structures, such as [hyperdrive.md](../building-blocks/hyperdrive.md "mention")s, that all share a common storage location:
|
||||
Namespacing is particularly useful if an application needs to create many different data structures, such as [hyperdrive.md](../building-blocks/hyperdrive.md)s, that all share a common storage location:
|
||||
|
||||
```javascript
|
||||
const store = new Corestore('./my-storage-dir')
|
||||
@@ -125,7 +125,7 @@ const drive2 = new Hyperdrive(store.namespace('drive-b'))
|
||||
|
||||
#### `const session = store.session([options])`
|
||||
|
||||
Creates a new Corestore that shares resources with the original, like cache, cores, replication streams, and storage, while optionally resetting the namespace, overriding `primaryKey`. Useful when an application wants to accept an optional Corestore, but needs to maintain a predictable key derivation.
|
||||
Creates a new Corestore that shares resources with the original, like cache, cores, replication streams, and storage, while optionally resetting the namespace, overriding `primaryKey`. Useful when an application needs to accept an optional Corestore, but needs to maintain a predictable key derivation.
|
||||
|
||||
`options` are the same as the constructor options:
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# Localdrive
|
||||
|
||||
A file system API that is similar to [hyperdrive.md](../building-blocks/hyperdrive.md "mention"). This tool comes in handy when mirroring files from user filesystem to a drive, and vice-versa.
|
||||
A file system API that is similar to [hyperdrive.md](../building-blocks/hyperdrive.md). This tool comes in handy when mirroring files from user filesystem to a drive, and vice-versa.
|
||||
|
||||
> [Github (Localdrive)](https://github.com/holepunchto/localdrive)
|
||||
> [GitHub (Localdrive)](https://github.com/holepunchto/localdrive)
|
||||
|
||||
* [Installation](localdrive.md#installation)
|
||||
* [Usage](localdrive.md#usage)
|
||||
@@ -80,7 +80,7 @@ String with the resolved (absolute) drive path.
|
||||
|
||||
Boolean that indicates if the drive handles or not metadata. Default `false`.
|
||||
|
||||
If you pass `options.metadata` hooks then `supportsMetadata` becomes true.
|
||||
If `options.metadata` hooks are passed then `supportsMetadata` becomes `true`.
|
||||
|
||||
**`await drive.put(key, buffer, [options])`**
|
||||
|
||||
@@ -146,7 +146,7 @@ Returns a stream of all subpaths of entries in drive stored at paths prefixed by
|
||||
|
||||
**`const mirror = drive.mirror(out, [options])`**
|
||||
|
||||
Mirrors this drive into another. Returns a [mirrordrive.md](../helpers/mirrordrive.md "mention") instance constructed with `options`.
|
||||
Mirrors this drive into another. Returns a [mirrordrive.md](../helpers/mirrordrive.md) instance constructed with `options`.
|
||||
|
||||
Call [`await mirror.done()`](../helpers/mirrordrive.md#await-mirrordone) to wait for the mirroring to finish.
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# MirrorDrive
|
||||
|
||||
Mirrors a [hyperdrive.md](../building-blocks/hyperdrive.md "mention") or a [localdrive.md](../helpers/localdrive.md "mention") into another one.
|
||||
Mirrors a [hyperdrive.md](../building-blocks/hyperdrive.md) or a [localdrive.md](../helpers/localdrive.md) into another one.
|
||||
|
||||
> [Github (Mirrordrive)](https://github.com/holepunchto/mirror-drive)
|
||||
> [GitHub (Mirrordrive)](https://github.com/holepunchto/mirror-drive)
|
||||
|
||||
* [Installation](./mirrordrive.md#installation)
|
||||
* [Basic usage](mirrordrive.md#basic-usage)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
Multiplex multiple message-oriented protocols over a stream
|
||||
|
||||
>[Github (Protomux)](https://github.com/mafintosh/protomux)
|
||||
>[GitHub (Protomux)](https://github.com/mafintosh/protomux)
|
||||
|
||||
* [Installation](protomux.md#installation)
|
||||
* [Basic usage](protomux.md#basic-usage)
|
||||
@@ -76,7 +76,7 @@ Makes a new instance. `stream` should be a framed stream, preserving the message
|
||||
|
||||
```javascript
|
||||
{
|
||||
// Called when the muxer wants to allocate a message that is written, defaults to Buffer.allocUnsafe.
|
||||
// Called when the muxer needs to allocate a message that is written, defaults to Buffer.allocUnsafe.
|
||||
alloc (size) {}
|
||||
}
|
||||
```
|
||||
@@ -99,7 +99,7 @@ Adds a new protocol channel.
|
||||
id: buffer,
|
||||
// Optional encoding for a handshake
|
||||
handshake: encoding,
|
||||
// Optional array of message types you want to send/receive.
|
||||
// Optional array of message types to send/receive.
|
||||
messages: [],
|
||||
// Called when the remote side adds this protocol.
|
||||
// Errors here are caught and forwarded to stream.destroy
|
||||
@@ -180,4 +180,4 @@ Same as `channel.uncork` but on the muxer instance.
|
||||
|
||||
#### **`for (const channel of muxer) { ... }`**
|
||||
|
||||
The muxer instance is iterable, so you can iterate over all the channels.
|
||||
The muxer instance is iterable so all channels can be iterated.
|
||||
|
||||
@@ -4,7 +4,7 @@ SecretStream is used to securely create connections between two peers in Hypersw
|
||||
|
||||
The SecretStream instance is a Duplex stream that supports usability as a normal stream for standard read/write operations. Furthermore, its payloads are encrypted with libsodium's SecretStream for secure transmission.
|
||||
|
||||
>[Github (SecretStream)](https://github.com/holepunchto/hyperswarm-secret-stream)
|
||||
>[GitHub (SecretStream)](https://github.com/holepunchto/hyperswarm-secret-stream)
|
||||
|
||||
* [SecretStream](secretstream.md#installation)
|
||||
* [Create a new instance](secretstream.md#const-s--new-secretstreamisinitiator-rawstream-options)
|
||||
@@ -35,7 +35,7 @@ npm install @hyperswarm/secret-stream
|
||||
|
||||
Makes a new stream.
|
||||
|
||||
`isInitiator` is a boolean indicating whether you are the client or the server.
|
||||
`isInitiator` is a boolean indicating whether the process is a client or the server.
|
||||
|
||||
`rawStream` can be set to an underlying transport stream to run the noise stream over.
|
||||
|
||||
@@ -43,12 +43,12 @@ Makes a new stream.
|
||||
|
||||
| Property | Description | Type |
|
||||
| :-------------------: | -------------------------------------------------------------------------- | ----------------------------------------------------- |
|
||||
| **`pattern`** | Accept server connections for this topic by announcing yourself to the DHT | String |
|
||||
| **`pattern`** | Accept server connections for this topic by announcing it to the DHT | String |
|
||||
| **`remotePublicKey`** | PublicKey of the other party | String |
|
||||
| **`keyPair`** | Combination of PublicKey and SecretKey | { publicKey, secretKey } |
|
||||
| **`handshake`** | To use a handshake performed elsewhere, pass it here | { tx, rx, handshakeHash, publicKey, remotePublicKey } |
|
||||
|
||||
The SecretStream returned is a Duplex stream that you use as a normal stream, to write/read data from, except its payloads are encrypted using the libsodium secretstream.
|
||||
The SecretStream returned is a Duplex stream to write data to and read data from, it's a normal stream with payloads that are encrypted using the libsodium secretstream.
|
||||
|
||||
> By default, the above process uses ed25519 for the handshakes.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user