diff --git a/docs/README.md b/docs/README.md index a5f69bc..56e4a50 100644 --- a/docs/README.md +++ b/docs/README.md @@ -4,7 +4,7 @@ torrefy / [Exports](modules.md)

torrefy

- GitHub top language npm version npm downloads GitHub search hit counter Rate this package + GitHub top language npm version npm downloads GitHub search hit counter Rate this package

An ESM package that uses Web Streams API to create v1, v2 or hybrid torrents in your web browser. @@ -49,8 +49,81 @@ const decodedMetaInfo = await decode(torrentStream2); ## Features -### Supports Different Web File APIs +### Supports Creating V1, V2 or Hybrid Torrents + +This package supports creating [V1](http://bittorrent.org/beps/bep_0003.html), [V2](https://www.bittorrent.org/beps/bep_0052.html) ([introduction blog](https://blog.libtorrent.org/2020/09/bittorrent-v2/)) or [Hybrid](https://www.bittorrent.org/beps/bep_0052.html#upgrade-path) ([introduction blog](https://blog.libtorrent.org/2020/09/bittorrent-v2/#:~:text=for%20backwards%20compatibility.-,backwards%20compatibility,-All%20new%20features)) torrents. + +### Covers Various Web File APIs This package can handle input files or directories acquired from [File API](https://developer.mozilla.org/docs/Web/API/File), [File and Directory Entries API](https://developer.mozilla.org/docs/Web/API/File_and_Directory_Entries_API) or [File System Access API](https://developer.mozilla.org/docs/Web/API/File_System_Access_API). -### TBD +### Supports Comprehensive Options + +TBD + +### Supports Handling Progress + +TBD + +### Exposes Stream-Based APIs + +The `create` function consumes an [iterable](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol) of input files as [`ReadableStream`](https://developer.mozilla.org/docs/Web/API/ReadableStream)s with options and populates a `MetaInfo` object. This function internally uses several [`TransformStream`](https://developer.mozilla.org/docs/Web/API/TransformStream)s to chop the files into pieces and hash them. + +The `encode` function consumes any bcodec friendly entity (e.g. `MetaInfo` object) and [bencode](http://bittorrent.org/beps/bep_0003.html#bencoding)s it into a `ReadableStream`. + +The `decode` function consumes any bcodec friendly `ReadableStream` (e.g. torrent `ReadableStream`) and bdecodes it into the corresponding entity. This function internally uses a `TransformStream` called `Tokenizer` to tokenize the input `ReadableStream` and then calls `parse` function to parse the `Tokens`. + +All `TransformStream`s used in this package are also exported. + +### Supports a Comprehensive Set of Bcodec Friendly Javascript Types + +Bcodec friendly Javascript types includes (for the time being): + +| Bcodec Type \ Javascript Type | `Strict` | `Loose` (`& Strict`) | +| :---------------------------: | :---------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------: | +| `ByteString` | [`string`](https://developer.mozilla.org/docs/Glossary/String) | [`ArrayBuffer`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) | +| `Integer` | [`number`](https://developer.mozilla.org/docs/Glossary/Number) [`bigint`](https://developer.mozilla.org/docs/Glossary/BigInt) | [`boolean`](https://developer.mozilla.org/docs/Glossary/Boolean) | +| `List` | [`Strict[]`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array) | `Loose[]` | +| `Dictionary` | [`{[key: string]: Strict}`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) | ` {[key: string]: Loose}`
[`Map`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map) | +| ignored | - | `undefined` `null` | + +`encode` function supports all `Loose` type inputs and `decode` function always returns `Strict` type results. + +### Supports Hooks in Bencoding + +> ⚠ The terminology may change in the future. + +You can register hooks when using the `encode` function. A common use case is extracting the bencoded `info` dictionary and calculating the [`infohash`](http://bittorrent.org/beps/bep_0052.html#infohash). (This package doesn't provide an out-of-box function to calculate `infohash` for now) + +To use hooks, you will have to install the peer dependency [`@sec-ant/trie-map`](https://www.npmjs.com/package/@sec-ant/trie-map), which allows you to register hook handlers with iterable paths as keys. You can learn more about this package in its [README](https://github.com/Sec-ant/trie-map). + +This package provides 3 helper functions to help you register hook handlers on hooks and consume their results as you please: `useUint8ArrayStreamHook`, `useArrayBufferPromiseHook`, `useTextPromiseHook`. + +Here is how you should use this feature: + +```ts +import { encode, EncoderHooks, useArrayBufferPromiseHook } from "torrefy"; +import { TrieMap } from "@sec-ant/trie-map"; + +// create a dummy object to encode +const dummyObject = { + a: "b", + c: 1, + info: { + foo: "bar", + }, + s: ["t"], +}; + +// initialize hooks for registration of hook handlers +const hooks: EncoderHooks = new TrieMap(); + +// register an array buffer promise hook under `dummyObject.info` +const [infoArrayBufferPromise] = useArrayBufferPromiseHook(["info"], hooks); + +// provide the hooks as an input argument into the encode function +const bencodedReadableStream = encode(dummyObject, hooks); + +// await the hook result +const infoArrayBuffer = await infoArrayBufferPromise; // => ArrayBuffer(12) +``` diff --git a/docs/classes/BlockHasher.md b/docs/classes/BlockHasher.md index 78320f8..72cab86 100644 --- a/docs/classes/BlockHasher.md +++ b/docs/classes/BlockHasher.md @@ -37,7 +37,7 @@ TransformStream<Uint8Array, Uint8Array[]\>.constructor #### Defined in -[src/transformers/blockHasher.ts:67](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/transformers/blockHasher.ts#L67) +[src/transformers/blockHasher.ts:67](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/transformers/blockHasher.ts#L67) ## Properties diff --git a/docs/classes/ChunkSplitter.md b/docs/classes/ChunkSplitter.md index a394ff5..aa24360 100644 --- a/docs/classes/ChunkSplitter.md +++ b/docs/classes/ChunkSplitter.md @@ -39,7 +39,7 @@ TransformStream<Uint8Array, Uint8Array\>.constructor #### Defined in -[src/transformers/chunkSplitter.ts:45](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/transformers/chunkSplitter.ts#L45) +[src/transformers/chunkSplitter.ts:45](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/transformers/chunkSplitter.ts#L45) ## Properties diff --git a/docs/classes/MerkleRootCalculator.md b/docs/classes/MerkleRootCalculator.md index d0794e3..4a8fcef 100644 --- a/docs/classes/MerkleRootCalculator.md +++ b/docs/classes/MerkleRootCalculator.md @@ -40,7 +40,7 @@ TransformStream< #### Defined in -[src/transformers/merkleRootCalculator.ts:28](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/transformers/merkleRootCalculator.ts#L28) +[src/transformers/merkleRootCalculator.ts:28](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/transformers/merkleRootCalculator.ts#L28) ## Properties diff --git a/docs/classes/MerkleTreeBalancer.md b/docs/classes/MerkleTreeBalancer.md index cd4e807..c66dea6 100644 --- a/docs/classes/MerkleTreeBalancer.md +++ b/docs/classes/MerkleTreeBalancer.md @@ -40,7 +40,7 @@ TransformStream< #### Defined in -[src/transformers/merkleTreeBalancer.ts:40](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/transformers/merkleTreeBalancer.ts#L40) +[src/transformers/merkleTreeBalancer.ts:40](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/transformers/merkleTreeBalancer.ts#L40) ## Properties diff --git a/docs/classes/PieceHasher.md b/docs/classes/PieceHasher.md index d6db846..5c2fd38 100644 --- a/docs/classes/PieceHasher.md +++ b/docs/classes/PieceHasher.md @@ -37,7 +37,7 @@ TransformStream<Uint8Array, Uint8Array\>.constructor #### Defined in -[src/transformers/pieceHasher.ts:32](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/transformers/pieceHasher.ts#L32) +[src/transformers/pieceHasher.ts:32](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/transformers/pieceHasher.ts#L32) ## Properties diff --git a/docs/classes/Tokenizer.md b/docs/classes/Tokenizer.md index 72a2852..d90a782 100644 --- a/docs/classes/Tokenizer.md +++ b/docs/classes/Tokenizer.md @@ -31,7 +31,7 @@ TransformStream<Uint8Array, Token\>.constructor #### Defined in -[src/transformers/tokenizer.ts:249](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/transformers/tokenizer.ts#L249) +[src/transformers/tokenizer.ts:248](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/transformers/tokenizer.ts#L248) ## Properties diff --git a/docs/enums/CommonPieceLength.md b/docs/enums/CommonPieceLength.md index a10bc0b..7255431 100644 --- a/docs/enums/CommonPieceLength.md +++ b/docs/enums/CommonPieceLength.md @@ -29,7 +29,7 @@ common piece lengths #### Defined in -[src/create.ts:398](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/create.ts#L398) +[src/create.ts:398](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/create.ts#L398) ___ @@ -39,7 +39,7 @@ ___ #### Defined in -[src/create.ts:395](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/create.ts#L395) +[src/create.ts:395](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/create.ts#L395) ___ @@ -49,7 +49,7 @@ ___ #### Defined in -[src/create.ts:405](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/create.ts#L405) +[src/create.ts:405](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/create.ts#L405) ___ @@ -59,7 +59,7 @@ ___ #### Defined in -[src/create.ts:401](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/create.ts#L401) +[src/create.ts:401](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/create.ts#L401) ___ @@ -69,7 +69,7 @@ ___ #### Defined in -[src/create.ts:399](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/create.ts#L399) +[src/create.ts:399](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/create.ts#L399) ___ @@ -79,7 +79,7 @@ ___ #### Defined in -[src/create.ts:402](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/create.ts#L402) +[src/create.ts:402](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/create.ts#L402) ___ @@ -89,7 +89,7 @@ ___ #### Defined in -[src/create.ts:396](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/create.ts#L396) +[src/create.ts:396](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/create.ts#L396) ___ @@ -99,7 +99,7 @@ ___ #### Defined in -[src/create.ts:406](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/create.ts#L406) +[src/create.ts:406](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/create.ts#L406) ___ @@ -109,7 +109,7 @@ ___ #### Defined in -[src/create.ts:403](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/create.ts#L403) +[src/create.ts:403](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/create.ts#L403) ___ @@ -119,7 +119,7 @@ ___ #### Defined in -[src/create.ts:400](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/create.ts#L400) +[src/create.ts:400](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/create.ts#L400) ___ @@ -129,7 +129,7 @@ ___ #### Defined in -[src/create.ts:397](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/create.ts#L397) +[src/create.ts:397](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/create.ts#L397) ___ @@ -139,4 +139,4 @@ ___ #### Defined in -[src/create.ts:404](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/create.ts#L404) +[src/create.ts:404](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/create.ts#L404) diff --git a/docs/enums/TokenType.md b/docs/enums/TokenType.md index 7261705..f553fba 100644 --- a/docs/enums/TokenType.md +++ b/docs/enums/TokenType.md @@ -12,7 +12,6 @@ - [Integer](TokenType.md#integer) - [ListEnd](TokenType.md#listend) - [ListStart](TokenType.md#liststart) -- [NewTokenType](TokenType.md#newtokentype) ## Enumeration Members @@ -22,7 +21,7 @@ #### Defined in -[src/transformers/tokenizer.ts:14](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/transformers/tokenizer.ts#L14) +[src/transformers/tokenizer.ts:14](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/transformers/tokenizer.ts#L14) ___ @@ -32,7 +31,7 @@ ___ #### Defined in -[src/transformers/tokenizer.ts:18](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/transformers/tokenizer.ts#L18) +[src/transformers/tokenizer.ts:18](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/transformers/tokenizer.ts#L18) ___ @@ -42,7 +41,7 @@ ___ #### Defined in -[src/transformers/tokenizer.ts:17](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/transformers/tokenizer.ts#L17) +[src/transformers/tokenizer.ts:17](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/transformers/tokenizer.ts#L17) ___ @@ -52,7 +51,7 @@ ___ #### Defined in -[src/transformers/tokenizer.ts:13](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/transformers/tokenizer.ts#L13) +[src/transformers/tokenizer.ts:13](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/transformers/tokenizer.ts#L13) ___ @@ -62,7 +61,7 @@ ___ #### Defined in -[src/transformers/tokenizer.ts:16](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/transformers/tokenizer.ts#L16) +[src/transformers/tokenizer.ts:16](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/transformers/tokenizer.ts#L16) ___ @@ -72,14 +71,4 @@ ___ #### Defined in -[src/transformers/tokenizer.ts:15](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/transformers/tokenizer.ts#L15) - -___ - -### NewTokenType - -• **NewTokenType** = ``"NewTokenType"`` - -#### Defined in - -[src/transformers/tokenizer.ts:19](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/transformers/tokenizer.ts#L19) +[src/transformers/tokenizer.ts:15](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/transformers/tokenizer.ts#L15) diff --git a/docs/enums/TorrentType.md b/docs/enums/TorrentType.md index 51d723a..76c1645 100644 --- a/docs/enums/TorrentType.md +++ b/docs/enums/TorrentType.md @@ -24,7 +24,7 @@ v1 + v2 hybrid torrent #### Defined in -[src/create.ts:61](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/create.ts#L61) +[src/create.ts:61](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/create.ts#L61) ___ @@ -38,7 +38,7 @@ v1 torrent #### Defined in -[src/create.ts:49](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/create.ts#L49) +[src/create.ts:49](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/create.ts#L49) ___ @@ -52,4 +52,4 @@ v2 torrent #### Defined in -[src/create.ts:55](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/create.ts#L55) +[src/create.ts:55](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/create.ts#L55) diff --git a/docs/interfaces/FilePropsV1.md b/docs/interfaces/FilePropsV1.md index 8cafefb..bb29d8e 100644 --- a/docs/interfaces/FilePropsV1.md +++ b/docs/interfaces/FilePropsV1.md @@ -40,7 +40,7 @@ FilePropsBase.attr #### Defined in -[src/utils/fileTree.ts:75](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileTree.ts#L75) +[src/utils/fileTree.ts:75](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileTree.ts#L75) ___ @@ -60,7 +60,7 @@ FilePropsBase.length #### Defined in -[src/utils/fileTree.ts:63](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileTree.ts#L63) +[src/utils/fileTree.ts:63](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileTree.ts#L63) ___ @@ -75,4 +75,4 @@ corresponding to **subdirectory** names #### Defined in -[src/utils/fileTree.ts:88](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileTree.ts#L88) +[src/utils/fileTree.ts:88](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileTree.ts#L88) diff --git a/docs/interfaces/FilePropsV2.md b/docs/interfaces/FilePropsV2.md index ff8a498..9fab994 100644 --- a/docs/interfaces/FilePropsV2.md +++ b/docs/interfaces/FilePropsV2.md @@ -40,7 +40,7 @@ FilePropsBase.attr #### Defined in -[src/utils/fileTree.ts:75](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileTree.ts#L75) +[src/utils/fileTree.ts:75](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileTree.ts#L75) ___ @@ -60,7 +60,7 @@ FilePropsBase.length #### Defined in -[src/utils/fileTree.ts:63](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileTree.ts#L63) +[src/utils/fileTree.ts:63](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileTree.ts#L63) ___ @@ -76,4 +76,4 @@ constructed from 16KiB blocks of the file #### Defined in -[src/utils/fileTree.ts:102](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileTree.ts#L102) +[src/utils/fileTree.ts:102](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileTree.ts#L102) diff --git a/docs/interfaces/FileTreeFileNode.md b/docs/interfaces/FileTreeFileNode.md index f8c5052..dd6f6ea 100644 --- a/docs/interfaces/FileTreeFileNode.md +++ b/docs/interfaces/FileTreeFileNode.md @@ -27,4 +27,4 @@ of the composed path at that point #### Defined in -[src/utils/fileTree.ts:120](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileTree.ts#L120) +[src/utils/fileTree.ts:120](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileTree.ts#L120) diff --git a/docs/modules.md b/docs/modules.md index fcc4e4f..97d3d60 100644 --- a/docs/modules.md +++ b/docs/modules.md @@ -34,7 +34,8 @@ - [BList](modules.md#blist) - [BMap](modules.md#bmap) - [BObject](modules.md#bobject) -- [EncodeHookHandler](modules.md#encodehookhandler) +- [EncoderHookHandler](modules.md#encoderhookhandler) +- [EncoderHooks](modules.md#encoderhooks) - [FileAttrs](modules.md#fileattrs) - [FileDirLike](modules.md#filedirlike) - [FileDirLikes](modules.md#filedirlikes) @@ -119,7 +120,7 @@ #### Defined in -[src/utils/codec.ts:11](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/codec.ts#L11) +[src/utils/codec.ts:11](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/codec.ts#L11) ___ @@ -135,7 +136,7 @@ ___ #### Defined in -[src/utils/codec.ts:53](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/codec.ts#L53) +[src/utils/codec.ts:53](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/codec.ts#L53) ___ @@ -151,7 +152,7 @@ ___ #### Defined in -[src/utils/codec.ts:36](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/codec.ts#L36) +[src/utils/codec.ts:36](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/codec.ts#L36) ___ @@ -167,7 +168,7 @@ ___ #### Defined in -[src/utils/codec.ts:4](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/codec.ts#L4) +[src/utils/codec.ts:4](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/codec.ts#L4) ___ @@ -183,7 +184,7 @@ ___ #### Defined in -[src/utils/codec.ts:18](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/codec.ts#L18) +[src/utils/codec.ts:18](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/codec.ts#L18) ___ @@ -193,7 +194,7 @@ ___ #### Defined in -[src/utils/codec.ts:32](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/codec.ts#L32) +[src/utils/codec.ts:32](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/codec.ts#L32) ___ @@ -209,13 +210,13 @@ ___ #### Defined in -[src/utils/codec.ts:29](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/codec.ts#L29) +[src/utils/codec.ts:29](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/codec.ts#L29) ___ -### EncodeHookHandler +### EncoderHookHandler -Ƭ **EncodeHookHandler**: (`result`: `IteratorResult`<`Uint8Array`, `undefined`\>) => `void` +Ƭ **EncoderHookHandler**: (`result`: `IteratorResult`<`Uint8Array`, `undefined`\>) => `void` #### Type declaration @@ -235,7 +236,19 @@ encode hook handler #### Defined in -[src/encode.ts:8](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/encode.ts#L8) +[src/encode.ts:8](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/encode.ts#L8) + +___ + +### EncoderHooks + +Ƭ **EncoderHooks**: `TrieMap`<`Iterable`<`string` \| `number`\>, [`EncoderHookHandler`](modules.md#encoderhookhandler)\> + +encoder hooks + +#### Defined in + +[src/encode.ts:15](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/encode.ts#L15) ___ @@ -247,7 +260,7 @@ file attributes #### Defined in -[src/utils/fileTree.ts:48](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileTree.ts#L48) +[src/utils/fileTree.ts:48](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileTree.ts#L48) ___ @@ -257,7 +270,7 @@ ___ #### Defined in -[src/utils/fileDirLike.ts:1](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileDirLike.ts#L1) +[src/utils/fileDirLike.ts:1](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileDirLike.ts#L1) ___ @@ -267,7 +280,7 @@ ___ #### Defined in -[src/utils/fileDirLike.ts:3](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileDirLike.ts#L3) +[src/utils/fileDirLike.ts:3](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileDirLike.ts#L3) ___ @@ -279,7 +292,7 @@ v2 dir entry #### Defined in -[src/utils/fileTree.ts:136](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileTree.ts#L136) +[src/utils/fileTree.ts:136](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileTree.ts#L136) ___ @@ -291,7 +304,7 @@ v2 file tree dir node #### Defined in -[src/utils/fileTree.ts:131](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileTree.ts#L131) +[src/utils/fileTree.ts:131](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileTree.ts#L131) ___ @@ -303,7 +316,7 @@ v2 file or dir entries #### Defined in -[src/utils/fileTree.ts:146](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileTree.ts#L146) +[src/utils/fileTree.ts:146](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileTree.ts#L146) ___ @@ -315,7 +328,7 @@ v2 file entry #### Defined in -[src/utils/fileTree.ts:126](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileTree.ts#L126) +[src/utils/fileTree.ts:126](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileTree.ts#L126) ___ @@ -327,7 +340,7 @@ v1 file list #### Defined in -[src/utils/fileTree.ts:108](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileTree.ts#L108) +[src/utils/fileTree.ts:108](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileTree.ts#L108) ___ @@ -345,7 +358,7 @@ info #### Defined in -[src/create.ts:295](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/create.ts#L295) +[src/create.ts:295](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/create.ts#L295) ___ @@ -363,7 +376,7 @@ meta info #### Defined in -[src/create.ts:376](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/create.ts#L376) +[src/create.ts:376](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/create.ts#L376) ___ @@ -388,7 +401,7 @@ ___ #### Defined in -[src/create.ts:455](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/create.ts#L455) +[src/create.ts:455](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/create.ts#L455) ___ @@ -400,7 +413,7 @@ v2 packed dir entry #### Defined in -[src/utils/fileTree.ts:141](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileTree.ts#L141) +[src/utils/fileTree.ts:141](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileTree.ts#L141) ___ @@ -412,7 +425,7 @@ v2 packed file or dir entries #### Defined in -[src/utils/fileTree.ts:151](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileTree.ts#L151) +[src/utils/fileTree.ts:151](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileTree.ts#L151) ___ @@ -424,7 +437,7 @@ v2 piece layers #### Defined in -[src/create.ts:308](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/create.ts#L308) +[src/create.ts:308](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/create.ts#L308) ___ @@ -434,7 +447,7 @@ ___ #### Defined in -[src/utils/fileTree.ts:184](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileTree.ts#L184) +[src/utils/fileTree.ts:184](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileTree.ts#L184) ___ @@ -458,7 +471,7 @@ ___ #### Defined in -[src/create.ts:1024](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/create.ts#L1024) +[src/create.ts:1024](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/create.ts#L1024) ___ @@ -474,7 +487,7 @@ ___ #### Defined in -[src/transformers/tokenizer.ts:48](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/transformers/tokenizer.ts#L48) +[src/transformers/tokenizer.ts:47](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/transformers/tokenizer.ts#L47) ___ @@ -492,7 +505,7 @@ torrent options #### Defined in -[src/create.ts:161](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/create.ts#L161) +[src/create.ts:161](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/create.ts#L161) ___ @@ -516,7 +529,7 @@ ___ #### Defined in -[src/utils/fileTree.ts:199](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileTree.ts#L199) +[src/utils/fileTree.ts:199](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileTree.ts#L199) ___ @@ -534,7 +547,7 @@ ___ #### Defined in -[src/create.ts:1030](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/create.ts#L1030) +[src/create.ts:1030](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/create.ts#L1030) ## Variables @@ -546,7 +559,7 @@ bencode buff: 0 (stands for 0) #### Defined in -[src/utils/codec.ts:125](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/codec.ts#L125) +[src/utils/codec.ts:125](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/codec.ts#L125) ___ @@ -558,7 +571,7 @@ bencode buff: : (stands for byte string length end) #### Defined in -[src/utils/codec.ts:105](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/codec.ts#L105) +[src/utils/codec.ts:105](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/codec.ts#L105) ___ @@ -570,7 +583,7 @@ bencode buff: d (stands for dictionary start) #### Defined in -[src/utils/codec.ts:75](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/codec.ts#L75) +[src/utils/codec.ts:75](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/codec.ts#L75) ___ @@ -582,7 +595,7 @@ bencode buff: e (stands for end) #### Defined in -[src/utils/codec.ts:85](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/codec.ts#L85) +[src/utils/codec.ts:85](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/codec.ts#L85) ___ @@ -594,7 +607,7 @@ bencode buff: i (stands for integer start) #### Defined in -[src/utils/codec.ts:95](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/codec.ts#L95) +[src/utils/codec.ts:95](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/codec.ts#L95) ___ @@ -606,7 +619,7 @@ bencode buff: l (stands for list start) #### Defined in -[src/utils/codec.ts:65](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/codec.ts#L65) +[src/utils/codec.ts:65](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/codec.ts#L65) ___ @@ -618,7 +631,7 @@ bencode buff: - (stands for -) #### Defined in -[src/utils/codec.ts:115](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/codec.ts#L115) +[src/utils/codec.ts:115](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/codec.ts#L115) ___ @@ -630,7 +643,7 @@ bencode byte: 0 (stands for 0) #### Defined in -[src/utils/codec.ts:120](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/codec.ts#L120) +[src/utils/codec.ts:120](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/codec.ts#L120) ___ @@ -642,7 +655,7 @@ bencode byte: : (stands for byte string length end) #### Defined in -[src/utils/codec.ts:100](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/codec.ts#L100) +[src/utils/codec.ts:100](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/codec.ts#L100) ___ @@ -654,7 +667,7 @@ bencode byte: d (stands for dictionary start) #### Defined in -[src/utils/codec.ts:70](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/codec.ts#L70) +[src/utils/codec.ts:70](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/codec.ts#L70) ___ @@ -666,7 +679,7 @@ bencode byte: e (stands for end) #### Defined in -[src/utils/codec.ts:80](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/codec.ts#L80) +[src/utils/codec.ts:80](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/codec.ts#L80) ___ @@ -678,7 +691,7 @@ bencode byte: i (stands for integer start) #### Defined in -[src/utils/codec.ts:90](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/codec.ts#L90) +[src/utils/codec.ts:90](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/codec.ts#L90) ___ @@ -690,7 +703,7 @@ bencode byte: l (stands for list start) #### Defined in -[src/utils/codec.ts:60](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/codec.ts#L60) +[src/utils/codec.ts:60](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/codec.ts#L60) ___ @@ -702,7 +715,7 @@ bencode byte: - (stands for -) #### Defined in -[src/utils/codec.ts:110](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/codec.ts#L110) +[src/utils/codec.ts:110](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/codec.ts#L110) ___ @@ -714,7 +727,7 @@ default block length 1 << 14 = 16384 #### Defined in -[src/create.ts:388](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/create.ts#L388) +[src/create.ts:388](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/create.ts#L388) ## Functions @@ -735,7 +748,7 @@ default block length 1 << 14 = 16384 #### Defined in -[src/utils/fileTree.ts:506](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileTree.ts#L506) +[src/utils/fileTree.ts:506](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileTree.ts#L506) ___ @@ -757,7 +770,7 @@ concat uint8 arrays #### Defined in -[src/utils/misc.ts:61](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/misc.ts#L61) +[src/utils/misc.ts:61](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/misc.ts#L61) ___ @@ -779,7 +792,7 @@ ___ #### Defined in -[src/create.ts:885](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/create.ts#L885) +[src/create.ts:885](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/create.ts#L885) ___ @@ -799,7 +812,7 @@ ___ #### Defined in -[src/decode.ts:130](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/decode.ts#L130) +[src/decode.ts:130](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/decode.ts#L130) ___ @@ -814,7 +827,7 @@ BEncode | Name | Type | | :------ | :------ | | `data` | `BDataLoose` | -| `hooks?` | `EncoderHooks` | +| `hooks?` | [`EncoderHooks`](modules.md#encoderhooks) | #### Returns @@ -824,7 +837,7 @@ readable stream of the bencoded data #### Defined in -[src/encode.ts:192](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/encode.ts#L192) +[src/encode.ts:195](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/encode.ts#L195) ___ @@ -844,7 +857,7 @@ ___ #### Defined in -[src/utils/fileDirLike.ts:69](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileDirLike.ts#L69) +[src/utils/fileDirLike.ts:69](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileDirLike.ts#L69) ___ @@ -864,7 +877,7 @@ ___ #### Defined in -[src/utils/fileDirLike.ts:82](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileDirLike.ts#L82) +[src/utils/fileDirLike.ts:82](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileDirLike.ts#L82) ___ @@ -903,7 +916,7 @@ index of the value in the sorted array and indexed result if found #### Defined in -[src/utils/misc.ts:9](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/misc.ts#L9) +[src/utils/misc.ts:9](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/misc.ts#L9) ___ @@ -925,7 +938,7 @@ is byte digit #### Defined in -[src/utils/codec.ts:132](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/codec.ts#L132) +[src/utils/codec.ts:132](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/codec.ts#L132) ___ @@ -945,7 +958,7 @@ fileDirLike is File #### Defined in -[src/utils/fileDirLike.ts:5](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileDirLike.ts#L5) +[src/utils/fileDirLike.ts:5](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileDirLike.ts#L5) ___ @@ -965,7 +978,7 @@ fileDirLike is FileSystemDirectoryEntry #### Defined in -[src/utils/fileDirLike.ts:9](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileDirLike.ts#L9) +[src/utils/fileDirLike.ts:9](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileDirLike.ts#L9) ___ @@ -985,7 +998,7 @@ fileDirLike is FileSystemDirectoryHandle #### Defined in -[src/utils/fileDirLike.ts:29](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileDirLike.ts#L29) +[src/utils/fileDirLike.ts:29](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileDirLike.ts#L29) ___ @@ -1005,7 +1018,7 @@ fileDirLike is FileSystemFileEntry #### Defined in -[src/utils/fileDirLike.ts:19](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileDirLike.ts#L19) +[src/utils/fileDirLike.ts:19](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileDirLike.ts#L19) ___ @@ -1025,7 +1038,7 @@ fileDirLike is FileSystemFileHandle #### Defined in -[src/utils/fileDirLike.ts:45](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileDirLike.ts#L45) +[src/utils/fileDirLike.ts:45](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileDirLike.ts#L45) ___ @@ -1045,7 +1058,7 @@ entry is FileTreeDirEntry #### Defined in -[src/utils/fileTree.ts:499](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileTree.ts#L499) +[src/utils/fileTree.ts:499](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileTree.ts#L499) ___ @@ -1065,7 +1078,7 @@ node is FileTreeDirNode #### Defined in -[src/utils/fileTree.ts:487](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileTree.ts#L487) +[src/utils/fileTree.ts:487](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileTree.ts#L487) ___ @@ -1085,7 +1098,7 @@ entry is FileTreeFileEntry #### Defined in -[src/utils/fileTree.ts:493](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileTree.ts#L493) +[src/utils/fileTree.ts:493](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileTree.ts#L493) ___ @@ -1105,7 +1118,7 @@ node is FileTreeFileNode #### Defined in -[src/utils/fileTree.ts:481](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileTree.ts#L481) +[src/utils/fileTree.ts:481](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileTree.ts#L481) ___ @@ -1136,7 +1149,7 @@ sorted array #### Defined in -[src/utils/misc.ts:44](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/misc.ts#L44) +[src/utils/misc.ts:44](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/misc.ts#L44) ___ @@ -1161,7 +1174,7 @@ root hash #### Defined in -[src/utils/misc.ts:90](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/misc.ts#L90) +[src/utils/misc.ts:90](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/misc.ts#L90) ___ @@ -1185,7 +1198,7 @@ next nearest power of 2 #### Defined in -[src/utils/misc.ts:80](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/misc.ts#L80) +[src/utils/misc.ts:80](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/misc.ts#L80) ___ @@ -1206,7 +1219,7 @@ ___ #### Defined in -[src/utils/fileTree.ts:456](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileTree.ts#L456) +[src/utils/fileTree.ts:456](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileTree.ts#L456) ___ @@ -1226,7 +1239,7 @@ ___ #### Defined in -[src/decode.ts:11](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/decode.ts#L11) +[src/decode.ts:11](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/decode.ts#L11) ___ @@ -1251,7 +1264,7 @@ file tree and a traverse function #### Defined in -[src/utils/fileTree.ts:209](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileTree.ts#L209) +[src/utils/fileTree.ts:209](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileTree.ts#L209) ___ @@ -1277,7 +1290,7 @@ ___ #### Defined in -[src/utils/fileTree.ts:156](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/utils/fileTree.ts#L156) +[src/utils/fileTree.ts:156](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/utils/fileTree.ts#L156) ___ @@ -1292,7 +1305,7 @@ Get an array buffer promise hook handler | Name | Type | | :------ | :------ | | `path` | `Iterable`<`string`\> | -| `hooks` | `EncoderHooks` | +| `hooks` | [`EncoderHooks`](modules.md#encoderhooks) | #### Returns @@ -1302,7 +1315,7 @@ an array buffer #### Defined in -[src/encode.ts:274](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/encode.ts#L274) +[src/encode.ts:277](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/encode.ts#L277) ___ @@ -1317,7 +1330,7 @@ Get an text promise hook handler | Name | Type | | :------ | :------ | | `path` | `Iterable`<`string`\> | -| `hooks` | `EncoderHooks` | +| `hooks` | [`EncoderHooks`](modules.md#encoderhooks) | #### Returns @@ -1327,7 +1340,7 @@ an text promise #### Defined in -[src/encode.ts:287](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/encode.ts#L287) +[src/encode.ts:290](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/encode.ts#L290) ___ @@ -1342,7 +1355,7 @@ Get a uint8 array stream hook handler | Name | Type | | :------ | :------ | | `path` | `Iterable`<`string`\> | -| `hooks` | `EncoderHooks` | +| `hooks` | [`EncoderHooks`](modules.md#encoderhooks) | #### Returns @@ -1352,4 +1365,4 @@ a uint8 array readable stream #### Defined in -[src/encode.ts:229](https://github.com/Sec-ant/bepjs/blob/5d0ef68/src/encode.ts#L229) +[src/encode.ts:232](https://github.com/Sec-ant/bepjs/blob/9d6a68a/src/encode.ts#L232)