Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Update README.md to enhance documentation and structure #82

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 85 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,106 @@
[![JSR @zsqk/somefn](https://jsr.io/badges/@zsqk/somefn)](https://jsr.io/@zsqk/somefn)
<a href="https://deno.land/x/somefn"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fdeno-visualizer.danopia.net%2Fshields%2Flatest-version%2Fx%2Fsomefn%2Fmod.ts" alt="somefn latest /x/ version" /></a>

some functions for deno
A collection of utility functions for Deno

**This project is still under development, and the parameters of the functions**
**are subject to change.**
**This project is still under development, and the parameters of the functions are subject to change.**

Generic JS Functions (Browser Environment Compatible):
## Generic JS Functions (Browser Environment Compatible)

- hash
### Cryptography & Hashing

- Hash Functions
- SHA1
- SHA256
- SHA512
- HMAC
- SHA256
- SHA512
- Uint8Array to hex string tools
[hexString()](https://deno.land/x/[email protected]/js/hash.ts?s=hexString)
- Text append BOM, for older Windows software
[textWithBOM()](https://deno.land/x/[email protected]/js/str.ts?s=textWithBOM)
- Generate random string (based on Web API `crypto`)
[genRandomString()](https://deno.land/x/[email protected]/js/str.ts?s=genRandomString)
- [RSA signing of data](https://deno.land/x/[email protected]/js/hash.ts?s=rasSign)
- RSA Data Signing
- Uint8Array to Hex String Utilities

### String Processing

- Text BOM Addition (for legacy Windows software)
- Random String Generation (using Web API `crypto`)
- LZ-string Compression/Decompression
- Unicode String Decoding

### Calculation & Logic

- Field Calculation (supports arithmetic operations)
- Logic Calculation (supports various comparison operators)
- Precise Decimal Calculation

### Data Processing

- UA Parser
- URL Parser
- Environment Variable Parser
- IP Address Utilities
- Date/Time Utilities
- Object/Array Operations

## Deno-specific Functions

### Git Operations

Functions that depend on the Deno runtime:
- Repository Cloning
- Change Detection
- Status Checking

- `gitChanges` View Git changes.
### File System

Other features:
- File Copying with Mapping
- Directory Operations

- CSV using the Deno standard library <https://deno.land/[email protected]/csv/mod.ts>
- XML recommends using `npm:fast-xml-parser`
- Uint8Array to HEX string <https://deno.land/[email protected]/encoding/hex.ts>
### System

## How to use
- Command Execution
- SSH Operations
- Computer Info Retrieval

## External Dependencies

- 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>

## Usage Examples

```ts
import { getComputeInfo } from "@zsqk/somefn";
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

// TODO
// 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
```

## License

MIT
Loading