tar-vern 0.3.0 → 1.1.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/README_pack.md +40 -6
- package/dist/extractor.d.ts +21 -0
- package/dist/extractor.d.ts.map +1 -0
- package/dist/index.cjs +377 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +365 -30
- package/dist/index.js.map +1 -1
- package/dist/packer.d.ts +2 -1
- package/dist/packer.d.ts.map +1 -1
- package/dist/types.d.ts +27 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +34 -8
- package/dist/utils.d.ts.map +1 -1
- package/package.json +19 -3
- package/LICENSE +0 -21
- package/README.md +0 -212
- package/dist/generated/packageMetadata.d.ts +0 -16
- package/dist/generated/packageMetadata.d.ts.map +0 -1
package/README_pack.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Tape archiver (tar) library for Typescript implementation.
|
4
4
|
|
5
|
-
[](https://www.repostatus.org/#active)
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
7
7
|
|
8
8
|
----
|
@@ -27,15 +27,15 @@ npm install tar-vern
|
|
27
27
|
|
28
28
|
----
|
29
29
|
|
30
|
-
##
|
31
|
-
|
32
|
-
### Minimum example
|
30
|
+
## Minimal sample code
|
33
31
|
|
34
32
|
tar-vern supplies file and directory information to pack through "TypeScript async generator."
|
35
33
|
This allows you to specify pack data with very concise code.
|
36
34
|
|
37
35
|
```typescript
|
38
|
-
import {
|
36
|
+
import {
|
37
|
+
createTarPacker, storeReaderToFile,
|
38
|
+
createFileItem, createDirectoryItem } from 'tar-vern';
|
39
39
|
|
40
40
|
// Create an async generator for tar entries
|
41
41
|
const itemGenerator = async function*() {
|
@@ -51,13 +51,47 @@ const itemGenerator = async function*() {
|
|
51
51
|
// (Make your own entries with yield expression...)
|
52
52
|
};
|
53
53
|
|
54
|
-
// Create
|
54
|
+
// Create GZipped tar stream and write to file
|
55
55
|
const packer = createTarPacker(itemGenerator(), 'gzip');
|
56
56
|
await storeReaderToFile(packer, 'archive.tar.gz'); // Use helper to awaitable
|
57
57
|
```
|
58
58
|
|
59
|
+
tar-vern provides tar extraction through async generator too, allowing you to process entries as they are extracted from the tar archive.
|
60
|
+
|
61
|
+
```typescript
|
62
|
+
import { createReadStream } from 'fs';
|
63
|
+
import { createTarExtractor } from 'tar-vern';
|
64
|
+
|
65
|
+
// Read GZipped tar file and extract entries
|
66
|
+
const readableStream = createReadStream('archive.tar.gz');
|
67
|
+
|
68
|
+
for await (const extractedItem of createTarExtractor(readableStream), 'gzip') {
|
69
|
+
if (extractedItem.kind === 'file') {
|
70
|
+
console.log(`File: ${extractedItem.path}`);
|
71
|
+
|
72
|
+
// Get content as string or buffer
|
73
|
+
const content = await extractedItem.getContent('string');
|
74
|
+
console.log(`Content: ${content}`);
|
75
|
+
} else {
|
76
|
+
console.log(`Directory: ${extractedItem.path}`);
|
77
|
+
}
|
78
|
+
}
|
79
|
+
```
|
80
|
+
|
59
81
|
----
|
60
82
|
|
83
|
+
## Features
|
84
|
+
|
85
|
+
- Bidirectional streaming: Both creation and extraction of tar archives
|
86
|
+
- Memory-efficient: Streaming API for processing large files without content buffering
|
87
|
+
- Multiple content sources: String, Buffer, ReadableStream, file paths and async generators
|
88
|
+
- Metadata preservation: File permissions, ownership, timestamps
|
89
|
+
- Built-in compression/decompression: GZip compression support (`tar.gz` format)
|
90
|
+
- Flexible content access: Extract files as string, Buffer, or Readable stream on demand
|
91
|
+
- Error handling: Comprehensive validation and error reporting
|
92
|
+
- Abort signal support: Cancellable operations
|
93
|
+
- No external dependencies: Pure TypeScript implementation
|
94
|
+
|
61
95
|
For more information, [see repository documents](http://github.com/kekyo/tar-vern/).
|
62
96
|
|
63
97
|
----
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/*!
|
2
|
+
* name: tar-vern
|
3
|
+
* version: 1.1.0
|
4
|
+
* description: Tape archiver library for Typescript
|
5
|
+
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
6
|
+
* license: MIT
|
7
|
+
* repository.url: https://github.com/kekyo/tar-vern.git
|
8
|
+
* git.commit.hash: 6d4ff13b538b16545ccc55b2e74f8e5f73999a34
|
9
|
+
*/
|
10
|
+
|
11
|
+
import { Readable } from 'stream';
|
12
|
+
import { CompressionTypes, ExtractedEntryItem } from './types';
|
13
|
+
/**
|
14
|
+
* Create a tar extractor
|
15
|
+
* @param readable - The readable stream containing tar data
|
16
|
+
* @param compressionType - The compression type (default: 'none')
|
17
|
+
* @param signal - The abort signal
|
18
|
+
* @returns Async generator of entry items
|
19
|
+
*/
|
20
|
+
export declare const createTarExtractor: (readable: Readable, compressionType?: CompressionTypes, signal?: AbortSignal) => AsyncGenerator<ExtractedEntryItem, void, unknown>;
|
21
|
+
//# sourceMappingURL=extractor.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"extractor.d.ts","sourceRoot":"","sources":["../src/extractor.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,EAAE,gBAAgB,EAA0B,kBAAkB,EAAqB,MAAM,SAAS,CAAC;AAmS1G;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAC7B,UAAU,QAAQ,EAClB,kBAAkB,gBAAgB,EAClC,SAAS,WAAW,KAAG,cAAc,CAAC,kBAAkB,EAAE,IAAI,EAAE,OAAO,CAyIxE,CAAC"}
|