aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorBiSaXa <1669855+BiSaXa@users.noreply.github.com>2022-09-11 10:37:36 +0300
committerBiSaXa <1669855+BiSaXa@users.noreply.github.com>2022-09-11 10:37:36 +0300
commit8d12a8d7592ee15d5ddc2136118ab750b4457cd1 (patch)
treed9654bd2569903285c642a1aa4ce2a4045302989 /README.md
parentadded go doc (diff)
downloadbitreader-8d12a8d7592ee15d5ddc2136118ab750b4457cd1.tar.gz
bitreader-8d12a8d7592ee15d5ddc2136118ab750b4457cd1.tar.bz2
bitreader-8d12a8d7592ee15d5ddc2136118ab750b4457cd1.zip
changed readme for new version
Diffstat (limited to '')
-rw-r--r--README.md36
1 files changed, 27 insertions, 9 deletions
diff --git a/README.md b/README.md
index 2954d37..b204345 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
1# BitReader [![Go Report Card](https://goreportcard.com/badge/github.com/bisaxa/bitreader)](https://goreportcard.com/report/github.com/bisaxa/bitreader) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/bisaxa/bitreader/blob/main/LICENSE) 1# BitReader [![Go Report Card](https://goreportcard.com/badge/github.com/bisaxa/bitreader)](https://goreportcard.com/report/github.com/bisaxa/bitreader) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/bisaxa/bitreader/blob/main/LICENSE) [![Go Reference](https://pkg.go.dev/badge/github.com/bisaxa/bitreader.svg)](https://pkg.go.dev/github.com/bisaxa/bitreader)
2A simple bit reader with big/little-endian support for golang.\ 2A simple bit reader with big/little-endian support for golang.\
3Reads data from an existing byte array.\ 3Reads data from an existing byte array.\
4Uses string manipulation (for now).\ 4Uses string manipulation (for now).\
@@ -15,24 +15,42 @@ $ go get github.com/bisaxa/bitreader
15```go 15```go
16import "github.com/bisaxa/bitreader" 16import "github.com/bisaxa/bitreader"
17 17
18// data: []byte Data to read from byte array 18// data: io.Reader Data to read from a io stream
19// le: bool Little-endian(true) or big-endian(false) state 19// le: bool Little-endian(true) or big-endian(false) state
20reader := bitreader.Reader(data, le) 20reader := bitreader.Reader(data, le)
21 21
22// read first bit 22// Read First Bit
23state, err := reader.ReadBit() 23state, err := reader.ReadBool()
24 24
25// skip bits/bytes 25// Skip Bits/Bytes
26err := reader.SkipBits(8) 26err := reader.SkipBits(8)
27err := reader.SkipBytes(4) 27err := reader.SkipBytes(4)
28 28
29// read bits 29// Read Bits/Bytes
30value, err := reader.ReadBits(11) 30value, err := reader.ReadBytes(4)
31value, err := reader.ReadBits(64) // up to 64 bits 31value, err := reader.ReadBits(64) // up to 64 bits
32
33// Wrapper functions
34state := reader.TryReadBool() // bool
35value := reader.TryReadInt1() // uint8
36value := reader.TryReadInt8() // uint8
37value := reader.TryReadInt16() // uint16
38value := reader.TryReadInt32() // uint32
39value := reader.TryReadInt64() // uint64
40value := reader.TryReadFloat32() // float32
41value := reader.TryReadFloat64() // float64
32``` 42```
33 43
34## Error Handling 44## Error Handling
35ReadBits(x), ReadBit(), SkipBits(x) and SkipBytes(x) functions returns an error message when they don't work as expected. It is advised to always handle errors. 45ReadBits(x), ReadBytes(x), ReadBool(), SkipBits(x) and SkipBytes(x) functions returns an error message when they don't work as expected. It is advised to always handle errors. \
46Wrapper functions, however, only returns the value and panics if an error is encountered.
47
48## Bug Report / Feature Request
49Using [Github Issues](https://github.com/BiSaXa/BitReader/issues/new/choose), you can report a bug that you encountered and/or request a feature that you would like to be added.
50
51## Documentation
52
53Full documentation can be found in https://pkg.go.dev/github.com/bisaxa/bitreader
36 54
37## License 55## License
38This project is licensed under [MIT License](LICENSE). \ No newline at end of file 56This project is licensed under [MIT License](LICENSE). \ No newline at end of file