rar-stream 1.3.2 → 1.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.travis.yml +2 -11
- package/README.md +33 -23
- package/example/package-lock.json +1191 -0
- package/example/package.json +2 -2
- package/package.json +5 -6
- package/src/__tests__/rar-file-chunk-test.js +4 -12
- package/src/inner-file.js +1 -1
- package/src/rar-file-chunk.js +1 -1
- package/src/rar-files-package.js +7 -1
package/.travis.yml
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
language: node_js
|
|
2
2
|
node_js:
|
|
3
|
-
- "
|
|
4
|
-
before_install:
|
|
5
|
-
# Repo for Yarn
|
|
6
|
-
- sudo apt-key adv --keyserver pgp.mit.edu --recv D101F7899D41F3C3
|
|
7
|
-
- echo "deb http://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
|
|
8
|
-
- sudo apt-get update -qq
|
|
9
|
-
- sudo apt-get install -y -qq yarn
|
|
10
|
-
cache:
|
|
11
|
-
directories:
|
|
12
|
-
- $HOME/.yarn-cache
|
|
3
|
+
- "8"
|
|
13
4
|
install:
|
|
14
|
-
-
|
|
5
|
+
- npm install
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Library for _"unpacking"_ and reading files inside rar archives as node Readable
|
|
|
5
5
|
|
|
6
6
|
__Note: Requires node version >= 8.0.0__
|
|
7
7
|
|
|
8
|
-
__Note:
|
|
8
|
+
__Note: Decompression is not implemented at the moment__
|
|
9
9
|
|
|
10
10
|
## Getting Started
|
|
11
11
|
Below example shows howto unpack local rar files by piping the inner files to the file system.
|
|
@@ -50,56 +50,66 @@ npm i rar-stream
|
|
|
50
50
|
|
|
51
51
|
### RarFilesPackage Api
|
|
52
52
|
|
|
53
|
-
```
|
|
54
|
-
// example
|
|
55
|
-
const rarFilesPackage = new RarFilesPackage(localRarFiles);
|
|
56
|
-
rarFilesPackage.on('parsing-start', rarFiles => console.log(rarFiles))
|
|
57
|
-
rarFilesPackage.on('file-parsed', innerFile => console.log(innerFile.name))
|
|
58
|
-
rarFilesPackage.on('parsing-end', innerFiles => console.log(innerFiles))
|
|
59
|
-
const innerFiles = await rarFilesPackage.parse();
|
|
60
|
-
```
|
|
61
|
-
|
|
62
53
|
#### Methods:
|
|
63
54
|
Method | Description
|
|
64
55
|
------|------------
|
|
65
|
-
_constructor_ | Takes an array of local file paths as strings or instances that satifies the [`FileMedia`](#filemedia-interface)
|
|
66
|
-
parse | Parses all rar files and returns a Promise with `InnerFile`s.
|
|
56
|
+
_constructor_ | Takes an array of local file paths as strings or instances that satifies the [`FileMedia`](#filemedia-interface) interface mentioned below.
|
|
57
|
+
parse | Parses all rar files and returns a Promise with [`InnerFile`](#innerfile-api)s.
|
|
67
58
|
|
|
68
59
|
#### Events:
|
|
69
60
|
Event | Description
|
|
70
61
|
------|------------
|
|
71
62
|
parsing-start | Emitted when the parsing is started, happens when you call `parse`. Event args are a bundle represntation of all the rar files passed to the constructor.
|
|
72
|
-
file-parsed | Emitted each time a
|
|
63
|
+
file-parsed | Emitted each time a rar file is parsed. The event argument is the RarFile just parsed, i.e `.rxx` in the chain.
|
|
73
64
|
parsing-complete | Emitted when the parsing is completed. The event argument is an array of all the parsed [`InnerFile`](#innerfile-api)s.
|
|
74
65
|
|
|
75
|
-
|
|
76
|
-
Implements the [`FileMedia`](#filemedia-interface) interface.
|
|
66
|
+
#### Example
|
|
77
67
|
```
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
68
|
+
const rarFilesPackage = new RarFilesPackage(localRarFiles);
|
|
69
|
+
rarFilesPackage.on('parsing-start', rarFiles => console.log(rarFiles))
|
|
70
|
+
rarFilesPackage.on('file-parsed', rarFile => console.log(rarFile.name))
|
|
71
|
+
rarFilesPackage.on('parsing-end', innerFiles => console.log(innerFiles))
|
|
72
|
+
const innerFiles = await rarFilesPackage.parse();
|
|
81
73
|
```
|
|
74
|
+
|
|
75
|
+
### InnerFile Api
|
|
76
|
+
Implements the [`FileMedia`](#filemedia-interface) interface.
|
|
77
|
+
|
|
82
78
|
#### Methods:
|
|
83
79
|
Method | Description
|
|
84
80
|
------|------------
|
|
85
|
-
createReadStream(start: number, end: number) | Returns a `Readable` stream. The start and end interval is inclusive.
|
|
81
|
+
createReadStream({start: number, end: number}) | Returns a `Readable` stream. The start and end interval is inclusive.
|
|
86
82
|
readToEnd | Returns a Promise with a Buffer containing all the content of the file.
|
|
87
83
|
|
|
88
84
|
#### Properties:
|
|
89
85
|
Property | Description
|
|
90
86
|
------|------------
|
|
91
87
|
name | The name of the file
|
|
92
|
-
length | Returns the number of bytes
|
|
88
|
+
length | Returns the total number of bytes of the file
|
|
89
|
+
|
|
90
|
+
#### Example
|
|
91
|
+
```
|
|
92
|
+
const innerFiles = await rarStreamPackage.parse();
|
|
93
|
+
const innerFileStream = innerFiles[0].createReadStream({ start: 0, end: 30});
|
|
94
|
+
```
|
|
93
95
|
|
|
94
96
|
### _FileMedia Interface_
|
|
95
97
|
This is loosely enforced interface that makes this module interoptable with other node modules such as [`torrent-stream`](https://www.npmjs.com/package/torrent-stream) or [`webtorrent`](https://www.npmjs.com/package/webtorrent).
|
|
96
98
|
|
|
97
99
|
Should have the following shape:
|
|
98
100
|
```javascript
|
|
101
|
+
// FileMedia
|
|
102
|
+
{
|
|
103
|
+
createReadStream(interval: Interval): Readable,
|
|
104
|
+
name: string,
|
|
105
|
+
length: number // Length or size of the file in bytes
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Interval
|
|
109
|
+
// start and end should be inclusive.
|
|
99
110
|
{
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
length: number // Length of the file
|
|
111
|
+
start: number,
|
|
112
|
+
end: number
|
|
103
113
|
}
|
|
104
114
|
```
|
|
105
115
|
|