A collection of utility functions for Deno
This project is still under development, and the parameters of the functions are subject to change.
- Hash Functions
- SHA1
- SHA256
- SHA512
- HMAC
- SHA256
- SHA512
- RSA Data Signing
- Uint8Array to Hex String Utilities
- Text BOM Addition (for legacy Windows software)
- Random String Generation (using Web API
crypto
) - LZ-string Compression/Decompression
- Unicode String Decoding
- Field Calculation (supports arithmetic operations)
- Logic Calculation (supports various comparison operators)
- Precise Decimal Calculation
- UA Parser
- URL Parser
- Environment Variable Parser
- IP Address Utilities
- Date/Time Utilities
- Object/Array Operations
- Repository Cloning
- Change Detection
- Status Checking
- File Copying with Mapping
- Directory Operations
- Command Execution
- SSH Operations
- Computer Info Retrieval
- CSV: Use Deno standard library https://deno.land/[email protected]/csv/mod.ts
- XML: Recommended to use
npm:fast-xml-parser
- Uint8Array to HEX: https://deno.land/[email protected]/encoding/hex.ts
import { hashString } from "@zsqk/somefn/js/hash";
import { fieldCalculate } from "@zsqk/somefn/js/calculate-field";
import { logicCalculate, LogicOperator } from "@zsqk/somefn/js/calculate-logic";
import { getWeekday } from "@zsqk/somefn/js/date";
// Hash calculation example
const hash = await hashString("hello world", "SHA-256");
console.log(hash); // Outputs SHA-256 hash value
// Field calculation example
const data = { price: 100, quantity: 2 };
const total = fieldCalculate(data, "price * quantity".split(" "));
console.log(total); // Output: 200
// Logic calculation example
const logicData = { age: 25, name: "John" };
const result = logicCalculate(logicData, {
condition: "AND",
rules: [
{ field: "age", operator: LogicOperator.greaterThan, value: 18 },
{ field: "name", operator: LogicOperator.equals, value: "John" }
]
});
console.log(result); // Output: true
// Date calculation example
const before = new Date("2024-01-01");
const after = new Date("2024-01-31");
const weekdays = getWeekday(before, after);
console.log(weekdays); // Outputs weekday statistics
MIT