- v2.3.2Latest
- v2.3.1
- v2.3.0
- v2.2.1
- v2.2.0
- v2.1.0
- v2.0.10
- v2.0.9
- v2.0.8
- v2.0.7
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.6.0
- v1.5.2
- v1.5.1
- v1.5.0
- v1.4.4
- v1.4.3
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.8
- v1.3.7
- v1.3.6
- v1.3.5
- v1.3.4
- v1.3.3
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.1
- v1.2.0
- v1.1.0
- v1.0.0
- v0.5.4
- v0.5.3
- v0.5.2
- v0.5.1
- v0.5.0
- v0.4.2
- v0.4.1
- v0.4.0
- v0.3.3
- v0.3.2
- v0.3.1
- v0.3.0
- v0.2.3
- v0.2.2
- v0.2.1
- v0.2.0
- v0.1.0
- v0.0.15
- v0.0.14
- v0.0.13
- v0.0.12
- v0.0.11
- v0.0.10
- v0.0.9
- v0.0.8
- v0.0.7
- v0.0.6
- v0.0.5
- v0.0.4
- v0.0.3
- v0.0.2
- v0.0.1
Simple Utility for Deno
A handy utility collection.
Example
BASE64 Binary
const file = await Deno.readFile("/path/to/binary.bin");
const encoded = base64Encode(file); // BASE64 encoded string.
const decoded = base64Decode(encoded); // Restored byte array.
DEFLATE Compress
const file = await Deno.readFile("/path/to/binary.bin");
const encoded = await deflateEncode(file); // DEFLATE compressed byte array.
const decoded = await deflateDecode(encoded); // Restored byte array.
Extended Fetch API
const json = await fetchExtend("https://path/to/get", "json"); // Response as JSON.
const bytes = await fetchExtend("https://path/to/get", "byte"); // Response as Uint8Array.
Minipack Archive
const files = [
new File([await Deno.readFile("/path/to/binary.bin")], "binary.bin")
];
const encoded = await minipackEncode(files); // Minipack archived byte array.
const decoded = await minipackDecode(encoded); // Restored file object array.
Details
It’s basically a thin wrapper around Deno’s functions to improve usability, but some features are original to this module.
This section describes the original features of this module.
Minipack
Minipack is a file archive format original to this module.
It’s structure is inspired by the famous “tar” and is minimal as an archive.
Originally developed for browsers, the purpose was to aggregate multiple files input with the HTML File API into a single file.
Therefore, there is no concept of directory or filesystem, and it’s feature by simple structure that stores only the file body, file name, and hash value for verification.
The actual binary structure looks like this:
Index | Type | Title | Size (Byte) |
---|---|---|---|
1 | Header | HashValue | 32 |
2 | Header | NameSize | 1 |
3 | Header | BodySize | 4 |
4 | Body | FileName | Max 255 (Defined in NameSize) |
5 | Body | FileBody | Max 4294967295 (Defined in BodySize) |
This is for one file and repeats for the number of files.
API
Uint8Array base64Encode(data)
data
… The byte array.
Uint8Array base64Decode(data)
data
… The BASE64 code.
Promise<Uint8Array> deflateEncode(data)
data
… The byte array.
Promise<Uint8Array> deflateDecode(data)
data
… The deflate compressed byte array.
<FetchResponseType<T>> fetchExtend<T>(path, type, option)
path
… Target URL. Since the query string is ignored, please specify it in theoption.query
property instead of writing it directly in the URL.type
… The type you want to receive in the response.option
… Fetch option.window
is removed fromRequestInit
andquery
is added to write the query string.
Promise<Uint8Array> minipackEncode(files)
files
… Array of file object.
Promise<File[]> minipackDecode(archive)
data
… The minipack archived byte array.