- 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
Show more details…
BASE64 Binary
const file = await Deno.readFile("/path/to/binary.bin");
const base64text = base64Encode(file);
const binary = base64Decode(base64text);
Easy WebCrypto
const file = await Deno.readFile("/path/to/binary.bin");
const uuid = cryptoUuid();
const random = cryptoRandom(16);
const hash = await cryptoHash(true, file);
const keyEcdh = await cryptoGenerateKey(true);
const keyEcdsa = await cryptoGenerateKey(false);
const encrypted = await cryptoEncrypt(keyEcdh, file);
const decrypted = await cryptoDecrypt(keyEcdh, encrypted);
const signature = await cryptoSign(keyEcdsa.privateKey, data);
const verify = await cryptoVerify(signature, keyEcdsa.publicKey, data);
DEFLATE Compress
const file = await Deno.readFile("/path/to/binary.bin");
const deflated = await deflateEncode(file);
const inflated = await deflateDecode(deflated);
Extended Fetch API
const json = await fetchExtend("https://path/to/get", "json");
const binary = await fetchExtend("https://path/to/get", "byte");
Minipack Archive
const files = [
["binary.bin", Deno.readFileSync("/path/to/binary.bin")]
];
const packed = await minipackEncode(files);
const unpacked = await minipackDecode(packed);
Text Convert
const text = " Lorem ipsum \t dolor \r sit amet.";
const binary1 = utfEncode(text);
const original = utfDecode(binary1);
const hextext = hexEncode(binary1);
const binary2 = hexDecode(hextext);
const formatted = trimExtend(text);
const emojis = accurateSegment("😄😁😆😅😂");
UnixTime Date
const time1 = unixtimeEncode();
const date = unixtimeDecode(time1);
const time2 = unixtimeParse(date.toISOString());
Path Operation (Deno Only)
const slash = unixSep("C:\\Users\\Administrator");
const backslash = windowsSep("C:/Users/Administrator");
const tmpdir = tmpPath();
const datadir = dataPath();
const homedir = homePath();
const maindir = mainPath();
Platform Specific (Deno Only)
const iswindows = isWindows();
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 web browser, the purpose was to aggregate multiple files input with the HTML File API into a single binary.
Therefore, there is no concept of directory or filesystem, and it’s feature by simple structure that stores only the file body and file name.
The actual binary structure looks like this:
Index | Type | Title | Size (Byte) |
---|---|---|---|
1 | Header | NameSize | 1 |
2 | Header | BodySize | 4 |
3 | Body | FileName | Max 255 (Defined in NameSize) |
4 | Body | FileBody | Max 4294967295 (Defined in BodySize) |
This is for one file and repeats for the number of files.
Browser Compatible
Some methods and classes in this module don’t use globalThis.Deno
internally and are browser compatible.
I have prepared browser compatible code only export as mod.universal.ts.
You can get bundled script in releases.
API
See Deno Document for details.