@push.rocks/smartarchive 4.0.39 → 4.2.0
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/dist_ts/00_commitinfo_data.js +2 -2
- package/dist_ts/bzip2/bititerator.js +7 -6
- package/dist_ts/bzip2/bzip2.js +76 -93
- package/dist_ts/bzip2/index.js +3 -2
- package/dist_ts/classes.archiveanalyzer.d.ts +1 -1
- package/dist_ts/classes.archiveanalyzer.js +2 -2
- package/dist_ts/classes.gziptools.js +2 -3
- package/dist_ts/classes.smartarchive.d.ts +1 -1
- package/dist_ts/classes.smartarchive.js +14 -6
- package/dist_ts/classes.tartools.js +3 -2
- package/dist_ts/classes.ziptools.d.ts +2 -1
- package/dist_ts/classes.ziptools.js +10 -9
- package/dist_ts/plugins.d.ts +1 -1
- package/dist_ts/plugins.js +2 -2
- package/npmextra.json +1 -1
- package/package.json +15 -16
- package/readme.md +239 -172
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/bzip2/bititerator.ts +40 -37
- package/ts/bzip2/bzip2.ts +259 -263
- package/ts/bzip2/index.ts +13 -3
- package/ts/classes.archiveanalyzer.ts +17 -8
- package/ts/classes.bzip2tools.ts +1 -1
- package/ts/classes.gziptools.ts +12 -6
- package/ts/classes.smartarchive.ts +78 -31
- package/ts/classes.tartools.ts +21 -9
- package/ts/classes.ziptools.ts +21 -12
- package/ts/paths.ts +1 -1
- package/ts/plugins.ts +11 -1
package/readme.md
CHANGED
|
@@ -1,266 +1,333 @@
|
|
|
1
|
-
# @push.rocks/smartarchive
|
|
1
|
+
# @push.rocks/smartarchive 📦
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Powerful archive manipulation for modern Node.js applications**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
`@push.rocks/smartarchive` is a versatile library for handling archive files with a focus on developer experience. Work with **zip**, **tar**, **gzip**, and **bzip2** formats through a unified, streaming-optimized API.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Features 🚀
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
- 📁 **Multi-format support** - Handle `.zip`, `.tar`, `.tar.gz`, `.tgz`, and `.bz2` archives
|
|
10
|
+
- 🌊 **Streaming-first architecture** - Process large archives without memory constraints
|
|
11
|
+
- 🔄 **Unified API** - Consistent interface across different archive formats
|
|
12
|
+
- 🎯 **Smart detection** - Automatically identifies archive types
|
|
13
|
+
- ⚡ **High performance** - Optimized for speed with parallel processing where possible
|
|
14
|
+
- 🔧 **Flexible I/O** - Work with files, URLs, and streams seamlessly
|
|
15
|
+
- 📊 **Archive analysis** - Inspect contents without extraction
|
|
16
|
+
- 🛠️ **Modern TypeScript** - Full type safety and excellent IDE support
|
|
12
17
|
|
|
13
|
-
|
|
18
|
+
## Installation 📥
|
|
14
19
|
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
```bash
|
|
21
|
+
# Using npm
|
|
22
|
+
npm install @push.rocks/smartarchive
|
|
18
23
|
|
|
19
|
-
|
|
24
|
+
# Using pnpm (recommended)
|
|
25
|
+
pnpm add @push.rocks/smartarchive
|
|
20
26
|
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
# Using yarn
|
|
28
|
+
yarn add @push.rocks/smartarchive
|
|
29
|
+
```
|
|
23
30
|
|
|
24
|
-
|
|
31
|
+
## Quick Start 🎯
|
|
25
32
|
|
|
26
|
-
|
|
33
|
+
### Extract an archive from URL
|
|
27
34
|
|
|
28
35
|
```typescript
|
|
29
36
|
import { SmartArchive } from '@push.rocks/smartarchive';
|
|
30
|
-
```
|
|
31
37
|
|
|
32
|
-
|
|
38
|
+
// Extract a .tar.gz archive from a URL directly to the filesystem
|
|
39
|
+
const archive = await SmartArchive.fromArchiveUrl(
|
|
40
|
+
'https://github.com/some/repo/archive/main.tar.gz'
|
|
41
|
+
);
|
|
42
|
+
await archive.exportToFs('./extracted');
|
|
43
|
+
```
|
|
33
44
|
|
|
34
|
-
|
|
45
|
+
### Process archive as a stream
|
|
35
46
|
|
|
36
47
|
```typescript
|
|
37
48
|
import { SmartArchive } from '@push.rocks/smartarchive';
|
|
38
49
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const archive = await SmartArchive.fromArchiveUrl(url);
|
|
44
|
-
await archive.exportToFs(targetDir);
|
|
50
|
+
// Stream-based processing for memory efficiency
|
|
51
|
+
const archive = await SmartArchive.fromArchiveFile('./large-archive.zip');
|
|
52
|
+
const streamOfFiles = await archive.exportToStreamOfStreamFiles();
|
|
45
53
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
54
|
+
// Process each file in the archive
|
|
55
|
+
streamOfFiles.on('data', (fileStream) => {
|
|
56
|
+
console.log(`Processing ${fileStream.path}`);
|
|
57
|
+
// Handle individual file stream
|
|
58
|
+
});
|
|
50
59
|
```
|
|
51
60
|
|
|
52
|
-
|
|
61
|
+
## Core Concepts 💡
|
|
53
62
|
|
|
54
|
-
|
|
63
|
+
### Archive Sources
|
|
55
64
|
|
|
56
|
-
|
|
57
|
-
import { SmartArchive } from '@push.rocks/smartarchive';
|
|
65
|
+
`SmartArchive` accepts archives from three sources:
|
|
58
66
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
67
|
+
1. **URL** - Download and process archives from the web
|
|
68
|
+
2. **File** - Load archives from the local filesystem
|
|
69
|
+
3. **Stream** - Process archives from any Node.js stream
|
|
62
70
|
|
|
63
|
-
|
|
64
|
-
await archive.exportToFs(targetDir);
|
|
71
|
+
### Export Destinations
|
|
65
72
|
|
|
66
|
-
|
|
67
|
-
}
|
|
73
|
+
Extract archives to multiple destinations:
|
|
68
74
|
|
|
69
|
-
|
|
70
|
-
|
|
75
|
+
1. **Filesystem** - Extract directly to a directory
|
|
76
|
+
2. **Stream of files** - Process files individually as streams
|
|
77
|
+
3. **Archive stream** - Re-stream as different format
|
|
71
78
|
|
|
72
|
-
|
|
79
|
+
## Usage Examples 🔨
|
|
73
80
|
|
|
74
|
-
|
|
81
|
+
### Working with ZIP files
|
|
75
82
|
|
|
76
83
|
```typescript
|
|
77
84
|
import { SmartArchive } from '@push.rocks/smartarchive';
|
|
78
|
-
import { createReadStream } from 'fs';
|
|
79
|
-
|
|
80
|
-
async function extractArchiveUsingStream() {
|
|
81
|
-
const archiveStream = createReadStream('/path/to/archive.zip');
|
|
82
|
-
const archive = await SmartArchive.fromArchiveStream(archiveStream);
|
|
83
|
-
const extractionStream = await archive.exportToStreamOfStreamFiles();
|
|
84
|
-
|
|
85
|
-
extractionStream.pipe(createWriteStream('/path/to/destination'));
|
|
86
|
-
}
|
|
87
85
|
|
|
88
|
-
|
|
86
|
+
// Extract a ZIP file
|
|
87
|
+
const zipArchive = await SmartArchive.fromArchiveFile('./archive.zip');
|
|
88
|
+
await zipArchive.exportToFs('./output');
|
|
89
|
+
|
|
90
|
+
// Stream ZIP contents for processing
|
|
91
|
+
const fileStream = await zipArchive.exportToStreamOfStreamFiles();
|
|
92
|
+
fileStream.on('data', (file) => {
|
|
93
|
+
if (file.path.endsWith('.json')) {
|
|
94
|
+
// Process JSON files from the archive
|
|
95
|
+
file.pipe(jsonProcessor);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
89
98
|
```
|
|
90
99
|
|
|
91
|
-
###
|
|
100
|
+
### Working with TAR archives
|
|
92
101
|
|
|
93
|
-
|
|
102
|
+
```typescript
|
|
103
|
+
import { SmartArchive, TarTools } from '@push.rocks/smartarchive';
|
|
104
|
+
|
|
105
|
+
// Extract a .tar.gz file
|
|
106
|
+
const tarGzArchive = await SmartArchive.fromArchiveFile('./archive.tar.gz');
|
|
107
|
+
await tarGzArchive.exportToFs('./extracted');
|
|
108
|
+
|
|
109
|
+
// Create a TAR archive (using TarTools directly)
|
|
110
|
+
const tarTools = new TarTools();
|
|
111
|
+
const packStream = await tarTools.packDirectory('./source-directory');
|
|
112
|
+
packStream.pipe(createWriteStream('./output.tar'));
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Extracting from URLs
|
|
94
116
|
|
|
95
117
|
```typescript
|
|
96
118
|
import { SmartArchive } from '@push.rocks/smartarchive';
|
|
97
119
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const analysisResult = await archive.analyzeContent();
|
|
103
|
-
|
|
104
|
-
console.log(analysisResult); // Outputs details about the archive content
|
|
105
|
-
}
|
|
120
|
+
// Download and extract in one operation
|
|
121
|
+
const remoteArchive = await SmartArchive.fromArchiveUrl(
|
|
122
|
+
'https://example.com/data.tar.gz'
|
|
123
|
+
);
|
|
106
124
|
|
|
107
|
-
|
|
108
|
-
|
|
125
|
+
// Extract to filesystem
|
|
126
|
+
await remoteArchive.exportToFs('./local-dir');
|
|
109
127
|
|
|
110
|
-
|
|
128
|
+
// Or process as stream
|
|
129
|
+
const stream = await remoteArchive.exportToStreamOfStreamFiles();
|
|
130
|
+
```
|
|
111
131
|
|
|
112
|
-
|
|
132
|
+
### Analyzing archive contents
|
|
113
133
|
|
|
114
134
|
```typescript
|
|
115
135
|
import { SmartArchive } from '@push.rocks/smartarchive';
|
|
116
136
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
// Add directories and files
|
|
121
|
-
archive.addedDirectories.push('/path/to/directory1');
|
|
122
|
-
archive.addedFiles.push('/path/to/file1.txt');
|
|
123
|
-
|
|
124
|
-
// Export as tar.gz
|
|
125
|
-
const tarGzStream = await archive.exportToTarGzStream();
|
|
126
|
-
|
|
127
|
-
// Save to filesystem or handle as needed
|
|
128
|
-
tarGzStream.pipe(createWriteStream('/path/to/destination.tar.gz'));
|
|
129
|
-
}
|
|
137
|
+
// Analyze without extracting
|
|
138
|
+
const archive = await SmartArchive.fromArchiveFile('./archive.zip');
|
|
139
|
+
const analyzer = archive.archiveAnalyzer;
|
|
130
140
|
|
|
131
|
-
|
|
141
|
+
// Use the analyzer to inspect contents
|
|
142
|
+
// (exact implementation depends on analyzer methods)
|
|
132
143
|
```
|
|
133
144
|
|
|
134
|
-
###
|
|
135
|
-
|
|
136
|
-
Here's an example of using `smartarchive`'s streaming capabilities:
|
|
145
|
+
### Working with GZIP files
|
|
137
146
|
|
|
138
147
|
```typescript
|
|
139
|
-
import {
|
|
140
|
-
import { SmartArchive } from '@push.rocks/smartarchive';
|
|
148
|
+
import { SmartArchive, GzipTools } from '@push.rocks/smartarchive';
|
|
141
149
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
150
|
+
// Decompress a .gz file
|
|
151
|
+
const gzipArchive = await SmartArchive.fromArchiveFile('./data.json.gz');
|
|
152
|
+
await gzipArchive.exportToFs('./decompressed', 'data.json');
|
|
153
|
+
|
|
154
|
+
// Use GzipTools directly for streaming
|
|
155
|
+
const gzipTools = new GzipTools();
|
|
156
|
+
const decompressStream = gzipTools.getDecompressionStream();
|
|
149
157
|
|
|
150
|
-
|
|
158
|
+
createReadStream('./compressed.gz')
|
|
159
|
+
.pipe(decompressStream)
|
|
160
|
+
.pipe(createWriteStream('./decompressed'));
|
|
151
161
|
```
|
|
152
162
|
|
|
153
|
-
###
|
|
163
|
+
### Working with BZIP2 files
|
|
154
164
|
|
|
155
|
-
|
|
165
|
+
```typescript
|
|
166
|
+
import { SmartArchive } from '@push.rocks/smartarchive';
|
|
156
167
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
168
|
+
// Handle .bz2 files
|
|
169
|
+
const bzipArchive = await SmartArchive.fromArchiveUrl(
|
|
170
|
+
'https://example.com/data.bz2'
|
|
171
|
+
);
|
|
172
|
+
await bzipArchive.exportToFs('./extracted', 'data.txt');
|
|
173
|
+
```
|
|
161
174
|
|
|
162
|
-
|
|
175
|
+
### Advanced streaming operations
|
|
163
176
|
|
|
164
177
|
```typescript
|
|
165
|
-
import { createReadStream, createWriteStream } from 'fs';
|
|
166
178
|
import { SmartArchive } from '@push.rocks/smartarchive';
|
|
179
|
+
import { pipeline } from 'stream/promises';
|
|
180
|
+
|
|
181
|
+
// Chain operations with streams
|
|
182
|
+
const archive = await SmartArchive.fromArchiveFile('./archive.tar.gz');
|
|
183
|
+
const exportStream = await archive.exportToStreamOfStreamFiles();
|
|
184
|
+
|
|
185
|
+
// Process each file in the archive
|
|
186
|
+
await pipeline(
|
|
187
|
+
exportStream,
|
|
188
|
+
async function* (source) {
|
|
189
|
+
for await (const file of source) {
|
|
190
|
+
if (file.path.endsWith('.log')) {
|
|
191
|
+
// Process log files
|
|
192
|
+
yield processLogFile(file);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
createWriteStream('./processed-logs.txt')
|
|
197
|
+
);
|
|
198
|
+
```
|
|
167
199
|
|
|
168
|
-
|
|
169
|
-
const filePath = '/path/to/archive.gz';
|
|
170
|
-
const targetDir = '/path/to/extract';
|
|
200
|
+
### Creating archives (advanced)
|
|
171
201
|
|
|
172
|
-
|
|
173
|
-
|
|
202
|
+
```typescript
|
|
203
|
+
import { SmartArchive } from '@push.rocks/smartarchive';
|
|
204
|
+
import { TarTools } from '@push.rocks/smartarchive';
|
|
174
205
|
|
|
175
|
-
|
|
176
|
-
|
|
206
|
+
// Using SmartArchive to create an archive
|
|
207
|
+
const archive = new SmartArchive();
|
|
177
208
|
|
|
178
|
-
|
|
179
|
-
|
|
209
|
+
// Add content to the archive
|
|
210
|
+
archive.addedDirectories.push('./src');
|
|
211
|
+
archive.addedFiles.push('./readme.md');
|
|
212
|
+
archive.addedFiles.push('./package.json');
|
|
180
213
|
|
|
181
|
-
|
|
214
|
+
// Export as TAR.GZ
|
|
215
|
+
const tarGzStream = await archive.exportToTarGzStream();
|
|
216
|
+
tarGzStream.pipe(createWriteStream('./output.tar.gz'));
|
|
217
|
+
```
|
|
182
218
|
|
|
183
|
-
|
|
219
|
+
### Extract and transform
|
|
184
220
|
|
|
185
221
|
```typescript
|
|
186
|
-
import {
|
|
187
|
-
import {
|
|
222
|
+
import { SmartArchive } from '@push.rocks/smartarchive';
|
|
223
|
+
import { Transform } from 'stream';
|
|
224
|
+
|
|
225
|
+
// Extract and transform files in one pipeline
|
|
226
|
+
const archive = await SmartArchive.fromArchiveUrl(
|
|
227
|
+
'https://example.com/source-code.tar.gz'
|
|
228
|
+
);
|
|
229
|
+
|
|
230
|
+
const extractStream = await archive.exportToStreamOfStreamFiles();
|
|
231
|
+
|
|
232
|
+
// Transform TypeScript to JavaScript during extraction
|
|
233
|
+
extractStream.on('data', (fileStream) => {
|
|
234
|
+
if (fileStream.path.endsWith('.ts')) {
|
|
235
|
+
fileStream
|
|
236
|
+
.pipe(typescriptTranspiler())
|
|
237
|
+
.pipe(createWriteStream(fileStream.path.replace('.ts', '.js')));
|
|
238
|
+
} else {
|
|
239
|
+
fileStream.pipe(createWriteStream(fileStream.path));
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
```
|
|
188
243
|
|
|
189
|
-
|
|
190
|
-
const filePath = '/path/to/archive.gz';
|
|
191
|
-
const targetDir = '/path/to/extract';
|
|
244
|
+
## API Reference 📚
|
|
192
245
|
|
|
193
|
-
|
|
194
|
-
const gzipTools = new GzipTools();
|
|
195
|
-
const decompressionStream = gzipTools.getDecompressionStream();
|
|
246
|
+
### SmartArchive Class
|
|
196
247
|
|
|
197
|
-
|
|
198
|
-
archiveStream.pipe(decompressionStream).pipe(createWriteStream(targetDir));
|
|
248
|
+
#### Static Methods
|
|
199
249
|
|
|
200
|
-
|
|
201
|
-
|
|
250
|
+
- `SmartArchive.fromArchiveUrl(url: string)` - Create from URL
|
|
251
|
+
- `SmartArchive.fromArchiveFile(path: string)` - Create from file
|
|
252
|
+
- `SmartArchive.fromArchiveStream(stream: NodeJS.ReadableStream)` - Create from stream
|
|
202
253
|
|
|
203
|
-
|
|
204
|
-
```
|
|
254
|
+
#### Instance Methods
|
|
205
255
|
|
|
206
|
-
|
|
256
|
+
- `exportToFs(targetDir: string, fileName?: string)` - Extract to filesystem
|
|
257
|
+
- `exportToStreamOfStreamFiles()` - Get a stream of file streams
|
|
258
|
+
- `exportToTarGzStream()` - Export as TAR.GZ stream
|
|
259
|
+
- `getArchiveStream()` - Get the raw archive stream
|
|
207
260
|
|
|
208
|
-
|
|
261
|
+
#### Properties
|
|
209
262
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const tarTools = new TarTools();
|
|
216
|
-
|
|
217
|
-
// Packing a directory into a tar stream
|
|
218
|
-
const packStream = await tarTools.packDirectory('/path/to/directory');
|
|
219
|
-
packStream.pipe(createWriteStream('/path/to/archive.tar'));
|
|
220
|
-
|
|
221
|
-
// Extracting files from a tar stream
|
|
222
|
-
const extractStream = tarTools.getDecompressionStream();
|
|
223
|
-
createReadStream('/path/to/archive.tar').pipe(extractStream).on('entry', (header, stream, next) => {
|
|
224
|
-
const writeStream = createWriteStream(`/path/to/extract/${header.name}`);
|
|
225
|
-
stream.pipe(writeStream);
|
|
226
|
-
stream.on('end', next);
|
|
227
|
-
});
|
|
228
|
-
}
|
|
263
|
+
- `archiveAnalyzer` - Analyze archive contents
|
|
264
|
+
- `tarTools` - TAR-specific operations
|
|
265
|
+
- `zipTools` - ZIP-specific operations
|
|
266
|
+
- `gzipTools` - GZIP-specific operations
|
|
267
|
+
- `bzip2Tools` - BZIP2-specific operations
|
|
229
268
|
|
|
230
|
-
|
|
231
|
-
```
|
|
269
|
+
### Specialized Tools
|
|
232
270
|
|
|
233
|
-
|
|
271
|
+
Each tool class provides format-specific operations:
|
|
234
272
|
|
|
235
|
-
|
|
273
|
+
- **TarTools** - Pack/unpack TAR archives
|
|
274
|
+
- **ZipTools** - Handle ZIP compression
|
|
275
|
+
- **GzipTools** - GZIP compression/decompression
|
|
276
|
+
- **Bzip2Tools** - BZIP2 operations
|
|
236
277
|
|
|
237
|
-
|
|
238
|
-
import { createReadStream, createWriteStream } from 'fs';
|
|
239
|
-
import { SmartArchive } from '@push.rocks/smartarchive';
|
|
278
|
+
## Performance Tips 🏎️
|
|
240
279
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
280
|
+
1. **Use streaming for large files** - Avoid loading entire archives into memory
|
|
281
|
+
2. **Process files in parallel** - Utilize stream operations for concurrent processing
|
|
282
|
+
3. **Choose the right format** - TAR.GZ for Unix systems, ZIP for cross-platform compatibility
|
|
283
|
+
4. **Enable compression wisely** - Balance between file size and CPU usage
|
|
244
284
|
|
|
245
|
-
|
|
246
|
-
const analyzedStream = archive.archiveAnalyzer.getAnalyzedStream();
|
|
247
|
-
const extractionStream = await archive.exportToStreamOfStreamFiles();
|
|
285
|
+
## Error Handling 🛡️
|
|
248
286
|
|
|
249
|
-
|
|
287
|
+
```typescript
|
|
288
|
+
import { SmartArchive } from '@push.rocks/smartarchive';
|
|
250
289
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
290
|
+
try {
|
|
291
|
+
const archive = await SmartArchive.fromArchiveUrl('https://example.com/file.zip');
|
|
292
|
+
await archive.exportToFs('./output');
|
|
293
|
+
} catch (error) {
|
|
294
|
+
if (error.code === 'ENOENT') {
|
|
295
|
+
console.error('Archive file not found');
|
|
296
|
+
} else if (error.code === 'EACCES') {
|
|
297
|
+
console.error('Permission denied');
|
|
298
|
+
} else {
|
|
299
|
+
console.error('Archive extraction failed:', error.message);
|
|
300
|
+
}
|
|
254
301
|
}
|
|
255
|
-
|
|
256
|
-
extractAndAnalyze();
|
|
257
302
|
```
|
|
258
303
|
|
|
259
|
-
|
|
304
|
+
## Real-World Use Cases 🌍
|
|
260
305
|
|
|
261
|
-
|
|
306
|
+
### Backup System
|
|
307
|
+
```typescript
|
|
308
|
+
// Automated backup extraction
|
|
309
|
+
const backup = await SmartArchive.fromArchiveFile('./backup.tar.gz');
|
|
310
|
+
await backup.exportToFs('/restore/location');
|
|
311
|
+
```
|
|
262
312
|
|
|
263
|
-
|
|
313
|
+
### CI/CD Pipeline
|
|
314
|
+
```typescript
|
|
315
|
+
// Download and extract build artifacts
|
|
316
|
+
const artifacts = await SmartArchive.fromArchiveUrl(
|
|
317
|
+
`${CI_SERVER}/artifacts/build-${BUILD_ID}.zip`
|
|
318
|
+
);
|
|
319
|
+
await artifacts.exportToFs('./dist');
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Data Processing
|
|
323
|
+
```typescript
|
|
324
|
+
// Process compressed datasets
|
|
325
|
+
const dataset = await SmartArchive.fromArchiveUrl(
|
|
326
|
+
'https://data.source/dataset.tar.bz2'
|
|
327
|
+
);
|
|
328
|
+
const files = await dataset.exportToStreamOfStreamFiles();
|
|
329
|
+
// Process each file in the dataset
|
|
330
|
+
```
|
|
264
331
|
|
|
265
332
|
## License and Legal Information
|
|
266
333
|
|
|
@@ -279,4 +346,4 @@ Registered at District court Bremen HRB 35230 HB, Germany
|
|
|
279
346
|
|
|
280
347
|
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
|
281
348
|
|
|
282
|
-
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
|
349
|
+
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
package/ts/00_commitinfo_data.ts
CHANGED
package/ts/bzip2/bititerator.ts
CHANGED
|
@@ -1,41 +1,44 @@
|
|
|
1
|
-
var BITMASK = [0, 0x01, 0x03, 0x07,
|
|
1
|
+
var BITMASK = [0, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff];
|
|
2
2
|
|
|
3
3
|
// returns a function that reads bits.
|
|
4
4
|
// takes a buffer iterator as input
|
|
5
5
|
export function bitIterator(nextBuffer: () => Buffer) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
6
|
+
var bit = 0,
|
|
7
|
+
byte = 0;
|
|
8
|
+
var bytes = nextBuffer();
|
|
9
|
+
var f = function (n) {
|
|
10
|
+
if (n === null && bit != 0) {
|
|
11
|
+
// align to byte boundary
|
|
12
|
+
bit = 0;
|
|
13
|
+
byte++;
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
var result = 0;
|
|
17
|
+
while (n > 0) {
|
|
18
|
+
if (byte >= bytes.length) {
|
|
19
|
+
byte = 0;
|
|
20
|
+
bytes = nextBuffer();
|
|
21
|
+
}
|
|
22
|
+
var left = 8 - bit;
|
|
23
|
+
if (bit === 0 && n > 0)
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
f.bytesRead++;
|
|
26
|
+
if (n >= left) {
|
|
27
|
+
result <<= left;
|
|
28
|
+
result |= BITMASK[left] & bytes[byte++];
|
|
29
|
+
bit = 0;
|
|
30
|
+
n -= left;
|
|
31
|
+
} else {
|
|
32
|
+
result <<= n;
|
|
33
|
+
result |=
|
|
34
|
+
(bytes[byte] & (BITMASK[n] << (8 - n - bit))) >> (8 - n - bit);
|
|
35
|
+
bit += n;
|
|
36
|
+
n = 0;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
f.bytesRead = 0;
|
|
43
|
+
return f;
|
|
44
|
+
}
|