-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3d3aa8d
Showing
44 changed files
with
5,968 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules/ | ||
test.js | ||
.idea/ | ||
test/data/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2024 Aternos GmbH | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# armarius-io | ||
|
||
## About | ||
|
||
This module contains implementations for reading from and writing to files, as well as implementations for | ||
deflate compression using various JavaScript APIs. | ||
It is mainly used by the [armarius](https://github.com/aternosorg/armarius/) module. | ||
|
||
Contained are IO contexts for Blob object (read only), ArrayBuffers, and Node.js FileHandle objects. | ||
Compression contexts exist for the [CompressionStreams API](https://developer.mozilla.org/en-US/docs/Web/API/CompressionStream), | ||
the Node.js zlib module, and the fflate library. | ||
|
||
## Installation | ||
|
||
Armarius-IO can be installed using npm: | ||
|
||
```shell | ||
npm install armarius-io | ||
``` | ||
|
||
## Usage | ||
|
||
### IO contexts | ||
|
||
IO contexts are objects that extend the `IO` class and can be used to read from or write to an underlying file or buffer. | ||
This library contains the following IO contexts: | ||
* `ArrayBufferIO` - for reading from and writing to an ArrayBuffer | ||
* `BlobIO` - for reading from a Blob or JavaScript File object | ||
* `NodeFileIO` - for reading from and writing to a Node.js FileHandle object | ||
|
||
#### ArrayBufferIO | ||
|
||
```javascript | ||
let data = new Uint8Array(123); | ||
let io = new ArrayBufferIO(data.buffer, data.byteOffset, data.byteLength); | ||
``` | ||
|
||
#### BlobIO | ||
|
||
```javascript | ||
let file = input.files[0]; | ||
let io = new BlobIO(file); | ||
``` | ||
|
||
#### NodeFileIO | ||
|
||
```javascript | ||
let file = await fs.promises.open('file.txt', 'r+'); | ||
let stat = await file.stat(); | ||
let io = new NodeFileIO(file, 0, stat.size); | ||
``` | ||
|
||
### DataStreams | ||
|
||
DataStream objects can be used to read data from a source. All IO contexts also implement `DataStream`. | ||
|
||
### DataProcessors | ||
|
||
DataProcessor objects read and transform data from a `DataStream`. This library includes DataProcessors for deflate compression using various JavaScript APIs. | ||
|
||
* `NativeDeflateDataProcessor` and `NativeInflateDataProcessor` - for using the [CompressionStreams API](https://developer.mozilla.org/en-US/docs/Web/API/CompressionStream) | ||
* `NodeDeflateDataProcessor` and `NodeInflateDataProcessor` - for using the Node.js zlib module | ||
* `FflateDeflateDataProcessor` and `FflateInflateDataProcessor` - for using the fflate library | ||
* `DefaultDeflateDataProcessor` and `DefaultInflateDataProcessor` - for using the best available compression method | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// DataProcessor | ||
export { default as AbstractDataProcessor } from "./src/DataProcessor/AbstractDataProcessor.js"; | ||
export { default as DataProcessor } from "./src/DataProcessor/DataProcessor.js"; | ||
export { default as DefaultDeflateDataProcessor } from "./src/DataProcessor/Default/DefaultDeflateDataProcessor.js"; | ||
export { default as DefaultInflateDataProcessor } from "./src/DataProcessor/Default/DefaultInflateDataProcessor.js"; | ||
export { default as FallbackDataProcessor } from "./src/DataProcessor/FallbackDataProcessor.js"; | ||
export { default as PassThroughDataProcessor } from "./src/DataProcessor/PassThroughDataProcessor.js"; | ||
export { default as DataProcessorChunkReader } from "./src/DataProcessor/DataProcessorChunkReader.js"; | ||
|
||
// DataProcessor/Fflate | ||
export { default as FflateDataProcessor } from "./src/DataProcessor/Fflate/FflateDataProcessor.js"; | ||
export { default as FflateDeflateDataProcessor } from "./src/DataProcessor/Fflate/FflateDeflateDataProcessor.js"; | ||
export { default as FflateInflateDataProcessor } from "./src/DataProcessor/Fflate/FflateInflateDataProcessor.js"; | ||
|
||
// DataProcessor/Native | ||
export { default as NativeDeflateDataProcessor } from "./src/DataProcessor/Native/NativeDeflateDataProcessor.js"; | ||
export { default as NativeInflateDataProcessor } from "./src/DataProcessor/Native/NativeInflateDataProcessor.js"; | ||
export { default as NativeStreamDataProcessor } from "./src/DataProcessor/Native/NativeStreamDataProcessor.js"; | ||
|
||
// IO | ||
export { default as ArrayBufferIO } from "./src/IO/ArrayBufferIO.js"; | ||
export { default as BlobIO } from "./src/IO/BlobIO.js"; | ||
export { default as DataStream } from "./src/IO/DataStream.js"; | ||
export { default as IO } from "./src/IO/IO.js"; | ||
|
||
// Util | ||
export { default as BigInt } from "./src/Util/BigInt.js"; | ||
export { default as BigIntUtils } from "./src/Util/BigIntUtils.js"; | ||
export { default as BufferUtils } from "./src/Util/BufferUtils.js"; | ||
export { default as CRC32 } from "./src/Util/CRC32.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
export * as constants from "./src/Constants.js"; | ||
|
||
// DataProcessor | ||
export { default as AbstractDataProcessor } from "./src/DataProcessor/AbstractDataProcessor.js"; | ||
export { default as DataProcessor } from "./src/DataProcessor/DataProcessor.js"; | ||
export { default as DefaultDeflateDataProcessor } from "./src/DataProcessor/Default/DefaultDeflateDataProcessor.js"; | ||
export { default as DefaultInflateDataProcessor } from "./src/DataProcessor/Default/DefaultInflateDataProcessor.js"; | ||
export { default as FallbackDataProcessor } from "./src/DataProcessor/FallbackDataProcessor.js"; | ||
export { default as PassThroughDataProcessor } from "./src/DataProcessor/PassThroughDataProcessor.js"; | ||
export { default as DataProcessorChunkReader } from "./src/DataProcessor/DataProcessorChunkReader.js"; | ||
|
||
// DataProcessor/Fflate | ||
export { default as FflateDataProcessor } from "./src/DataProcessor/Fflate/FflateDataProcessor.js"; | ||
export { default as FflateDeflateDataProcessor } from "./src/DataProcessor/Fflate/FflateDeflateDataProcessor.js"; | ||
export { default as FflateInflateDataProcessor } from "./src/DataProcessor/Fflate/FflateInflateDataProcessor.js"; | ||
|
||
// DataProcessor/Native | ||
export { default as NativeDeflateDataProcessor } from "./src/DataProcessor/Native/NativeDeflateDataProcessor.js"; | ||
export { default as NativeInflateDataProcessor } from "./src/DataProcessor/Native/NativeInflateDataProcessor.js"; | ||
export { default as NativeStreamDataProcessor } from "./src/DataProcessor/Native/NativeStreamDataProcessor.js"; | ||
|
||
// DataProcessor/Node | ||
export { default as NodeDeflateDataProcessor } from "./src/DataProcessor/Node/NodeDeflateDataProcessor.js"; | ||
export { default as NodeInflateDataProcessor } from "./src/DataProcessor/Node/NodeInflateDataProcessor.js"; | ||
export { default as NodeStreamDataProcessor } from "./src/DataProcessor/Node/NodeStreamDataProcessor.js"; | ||
|
||
// IO | ||
export { default as ArrayBufferIO } from "./src/IO/ArrayBufferIO.js"; | ||
export { default as BlobIO } from "./src/IO/BlobIO.js"; | ||
export { default as DataStream } from "./src/IO/DataStream.js"; | ||
export { default as NodeFileIO } from "./src/IO/NodeFileIO.js"; | ||
export { default as IO } from "./src/IO/IO.js"; | ||
|
||
// Util | ||
export { default as BigInt } from "./src/Util/BigInt.js"; | ||
export { default as BigIntUtils } from "./src/Util/BigIntUtils.js"; | ||
export { default as BufferUtils } from "./src/Util/BufferUtils.js"; | ||
export { default as CRC32 } from "./src/Util/CRC32.js"; |
Oops, something went wrong.