Skip to content

Commit bb1b56a

Browse files
Update README.md
1 parent 21d9bbe commit bb1b56a

File tree

1 file changed

+57
-53
lines changed

1 file changed

+57
-53
lines changed

README.md

Lines changed: 57 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -4,115 +4,119 @@
44

55
# ByteFlow.Net
66

7-
[![Build](https://github.com/AndrewClements84/ByteFlow.Net/actions/workflows/dotnet.yml/badge.svg)](https://github.com/AndrewClements84/ByteFlow.Net/actions)
8-
[![codecov](https://codecov.io/gh/AndrewClements84/ByteFlow.Net/branch/master/graph/badge.svg)](https://codecov.io/gh/AndrewClements84/ByteFlow.Net)
9-
[![NuGet Version](https://img.shields.io/nuget/v/ByteFlow.Net.svg?logo=nuget&cacheSeconds=300)](https://www.nuget.org/packages/ByteFlow.Net)
10-
[![NuGet Downloads](https://img.shields.io/nuget/dt/ByteFlow.Net.svg)](https://www.nuget.org/packages/ByteFlow.Net)
11-
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE.txt)
7+
[![Build](https://github.com/AndrewClements84/ByteFlow.Net/actions/workflows/dotnet.yml/badge.svg)](https://github.com/AndrewClements84/ByteFlow.Net/actions)
8+
[![codecov](https://codecov.io/gh/AndrewClements84/ByteFlow.Net/branch/master/graph/badge.svg)](https://codecov.io/gh/AndrewClements84/ByteFlow.Net)
9+
[![NuGet Version](https://img.shields.io/nuget/v/ByteFlow.Net.svg?logo=nuget&cacheSeconds=300)](https://www.nuget.org/packages/ByteFlow.Net)
10+
[![NuGet Downloads](https://img.shields.io/nuget/dt/ByteFlow.Net.svg)](https://www.nuget.org/packages/ByteFlow.Net)
11+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE.txt)
1212
![GitHub Repo stars](https://img.shields.io/github/stars/AndrewClements84/ByteFlow.Net?style=flat&color=2bbc8a)
1313

14-
A lightweight .NET library for converting bytes into **human-readable
15-
formats** (KB, MB, GB, etc.) and back again.
14+
ByteFlow.Net — Convert bytes ⇄ human-readable formats with SI, IEC, culture-aware, and customizable units. Zero dependencies.
1615

1716
---
1817

1918
## ✨ Features
2019

21-
- Convert bytes into human-readable strings (`1234567 → "1.18 MB"`).
22-
- Parse strings back into bytes (`"2.5 GB" → 2684354560`).
23-
- Safe parsing with `TryParseHumanBytes`.
24-
- Zero dependencies, just clean C#.
25-
- Works on .NET Framework (4.6.1+) and all modern .NET versions (Core,
26-
5/6/7/8).
20+
- Convert raw byte counts into human-readable strings (e.g. `1234567 → "1.23 MB"`)
21+
- Parse human-readable strings back into bytes (`"2.5 GB" → 2684354560`)
22+
- Safe parsing via `TryParseHumanBytes` (no exception)
23+
- Support for both **IEC (KiB, MiB, GiB)** and **SI (KB, MB, GB)** unit standards
24+
- Culture-aware parsing/formatting (e.g. `"1,5 MB"` for cultures with comma decimal separators)
25+
- Customizable suffix sets (allow defining your own unit names/factors)
26+
- Alignment/padding helpers for nicely formatted output in tables or logs
27+
- Fully tested with **100% code coverage**
28+
- Zero external dependencies — pure C#
2729

2830
---
2931

3032
## 📦 Installation
3133

32-
Install from [NuGet](https://www.nuget.org/packages/ByteFlow.Net):
34+
Install via NuGet:
3335

34-
``` sh
36+
```bash
3537
dotnet add package ByteFlow.Net
3638
```
3739

3840
---
3941

4042
## 🚀 Usage
4143

42-
``` csharp
43-
using ByteFlowNet;
44+
```csharp
45+
using ByteFlow;
4446

45-
// Convert bytes to human-readable string
47+
// Basic conversion
4648
long size = 1234567;
47-
Console.WriteLine(size.ToHumanBytes()); // "1.18 MB"
48-
Console.WriteLine(size.ToHumanBytes(3)); // "1.177 MB"
49+
Console.WriteLine(size.ToHumanBytes()); // e.g. "1.18 MB" (default settings)
50+
Console.WriteLine(size.ToHumanBytes(3)); // more decimals
4951
50-
// Parse string back into bytes
51-
long bytes = "2.5 GB".ToBytes(); // 2684354560
52+
// Parsing string to bytes
53+
long bytes = "2.5 GB".ToBytes(); // default parsing (SI/IEC based on default)
5254
Console.WriteLine(bytes);
5355

5456
// Safe parsing
5557
if ("10 MB".TryParseHumanBytes(out var val))
5658
{
57-
Console.WriteLine(val); // 10485760
59+
Console.WriteLine(val); // prints bytes if successful
5860
}
61+
62+
// Using IEC explicitly
63+
Console.WriteLine(1536L.ToHumanBytes(2, UnitStandard.IEC)); // "1.50 KiB"
64+
long val2 = "1.50 KiB".ToBytes(UnitStandard.IEC);
65+
66+
// Culture-aware parsing/formatting
67+
var de = new System.Globalization.CultureInfo("de-DE");
68+
Console.WriteLine((1500L).ToHumanBytes(2, UnitStandard.SI, de)); // "1,50 KB"
69+
long val3 = "1,50 KB".ToBytes(UnitStandard.SI, de);
70+
71+
// Custom suffix sets
72+
var custom = new[] { ("X", 1d), ("KX", 1000d), ("MX", 1000000d) };
73+
string customStr = 5000L.ToHumanBytes(2, UnitStandard.SI, null, custom); // "5.00 KX"
74+
long customBytes = "5 KX".ToBytes(UnitStandard.SI, null, custom);
5975
```
6076

6177
---
6278

63-
## 🧪 Unit Tests
64-
65-
Unit tests are included under the `tests/ByteFlowNet.Tests` project
66-
using **xUnit**.
79+
## 🧪 Unit Tests & Code Coverage
6780

81+
Unit tests are under `ByteFlow.Tests` (xUnit).
6882
Run them with:
6983

70-
``` sh
84+
```bash
7185
dotnet test
7286
```
7387

74-
---
75-
76-
## 📊 Code Coverage
77-
78-
Code coverage reports are automatically uploaded to
79-
[Codecov](https://app.codecov.io/gh/AndrewClements84/ByteFlow.Net).\
80-
Current coverage: **100%**
88+
Coverage is tracked via Codecov — current coverage: **100%**
8189

8290
---
8391

84-
## 🔮 Roadmap
92+
## 🧭 Alternatives / Comparisons
8593

86-
Planned features for upcoming releases:
94+
While there are other “bytes to human readable” .NET libraries out there, very few (if any) offer the combined feature set that **ByteFlow.Net** does:
8795

88-
- [ ] Support for both **IEC (binary: KiB, MiB)** and **SI (decimal:
89-
KB, MB)** unit standards\
90-
- [ ] Culture-aware parsing (e.g., commas vs dots for decimals)\
91-
- [ ] Customizable suffix sets (allowing non-standard units)\
92-
- [ ] Performance benchmarking and optimizations for very large
93-
inputs\
94-
- [ ] Additional helpers for formatting with alignment/padding
96+
- Support for both **IEC and SI**
97+
- Culture-aware parsing/formatting
98+
- Fully customizable suffix sets
99+
- Alignment/padding helpers
100+
- Zero dependencies
101+
- Complete test coverage
102+
103+
So this library aims to be a robust one-stop solution for byte-size formatting.
95104

96105
---
97106

98107
## 🤝 Contributing
99108

100-
Contributions, issues, and feature requests are welcome!\
101-
Feel free to open a
102-
[discussion](https://github.com/AndrewClements84/ByteFlow.Net/discussions)
103-
or a [pull
104-
request](https://github.com/AndrewClements84/ByteFlow.Net/pulls).
109+
Contributions, issues, and feature requests are always welcome!
110+
Feel free to open a [discussion](https://github.com/AndrewClements84/ByteFlow.Net/discussions) or a [pull request](https://github.com/AndrewClements84/ByteFlow.Net/pulls).
105111

106112
---
107113

108114
## ⭐ Support
109115

110-
If you find **ByteFlow.Net** useful, please consider giving it a star on
111-
GitHub --- it helps others discover the project and shows your support.
116+
If you enjoy using **ByteFlow.Net**, a GitHub star helps more than you’d think — it boosts visibility and helps others find it.
112117

113118
---
114119

115-
116120
## 📄 License
117121

118-
This project is licensed under the MIT License see the [LICENSE.txt](LICENSE.txt) file for details.
122+
Licensed under the MIT License see [LICENSE.txt](LICENSE.txt) for details.

0 commit comments

Comments
 (0)