Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/simple_utility/mod.ts

Useful snippet collection.
Go to Latest
import * as simpleUtility from "https://deno.land/x/simple_utility@v0.5.4/mod.ts";

Functions

Accurately recognize string that contain character above 0x010000 and array them one by character. Useful for calculate number of characters with string contains emoji.

Convert from base64 encoded string to binary.

Convert from binary to base64 encoded string.

Wrapper function of jsonLoad(). Config file path is fixed ${Deno.mainModule}/config.json.

Return system-wide application data directory path for each OS. /var for UNIX and C:/ProgramData for Windows.

Decompress "deflate" format binary. Cannot decompress such as "gzip" (RFC1952) or "zlib" (RFC1950) that contain header.

Compress binary with "deflate" format. Does not contain header such as "gzip" (RFC1952) or "zlib" (RFC1950).

Extended fetch function that can specify response type directly.

Derive SHA2 hash value from binary.

Convert from hex string to binary.

Convert from binary to hex string.

Return system-wide home path for each OS. ${HOME} for UNIX and %USERPROFILE% for Windows.

Are you running on Windows?

Read JSON file and convert to object. If JSON file does not exist create new file with default value. Argument default value also act as type definition.

Read JSON file and convert to object.

Convert from object to JSON and write to file.

Instantiate logger with general configuration. Output to console and file. Log file default save path is ${Deno.mainModule}/execution.log.

Return directory of Deno.mainModule.

Decode byte array in "minipack" format.

Concatenate files with "minipack" format.

Decrypt binary. Algorithm use is "AES-GCM" with 256 bits key, 128 bits tag and 96 bits IV. IV is read from head of cipher.

Encrypt binary. Algorithm use is "AES-GCM" with 256 bits key, 128 bits tag and 96 bits IV. IV is prepended to cipher.

Generate exportable public-key pair. You can generate keys for ECDH or ECDSA. Algorithm use is "NIST P-512".

Create signature using private-key.

Verify signature using public-key.

Generate random binary with any number of bytes.

Generate UUIDv4 string.

Run command as subprocess.

Convert from backslash to slash. Useful for converting from Windows path to UNIX path.

Convert from slash to backslash. Useful for converting from UNIX path to Windows path.

Return system-wide temporary directory path for each OS. /tmp for UNIX and C:/Windows/Temp for Windows.

Trim head and tail blank, remove CR and consecutive space (tab, LF) to single space (tab, LF).

Returns Date from UNIX time. Note that in seconds not milliseconds.

Return UNIX time in seconds. If no argument will be calculate at current time.

Convert from formatted datetime string such as ISO8601 to UNIX time in seconds.

Convert from UTF-8 binary to string.

Convert from string to UTF-8 binary.

Interfaces

RequestInit with added query property that can specify query string.

Map of fetch response type and string specify them.

Type Aliases

Simple filename and binary pair that make up file.

Serialized CryptoKeyPair.

Possible input for URLSearchParams.