{"id":31807862,"url":"https://github.com/funvibe/funbit","last_synced_at":"2026-04-18T12:04:03.496Z","repository":{"id":314685260,"uuid":"1055885475","full_name":"funvibe/funbit","owner":"funvibe","description":"Library for working with bit strings according to the Erlang specification","archived":false,"fork":false,"pushed_at":"2025-11-10T16:35:37.000Z","size":211,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-10T18:22:21.196Z","etag":null,"topics":["binary","bitstring","erlang","erlang-otp","go","golang","golang-library","library","matching","pattern-matching"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/funvibe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-13T01:19:35.000Z","updated_at":"2025-11-10T16:35:40.000Z","dependencies_parsed_at":"2025-09-30T12:01:56.956Z","dependency_job_id":"ea0da4c3-0774-45e5-8413-509cf3b57fd1","html_url":"https://github.com/funvibe/funbit","commit_stats":null,"previous_names":["funvibe/funbit"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/funvibe/funbit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funvibe%2Ffunbit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funvibe%2Ffunbit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funvibe%2Ffunbit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funvibe%2Ffunbit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/funvibe","download_url":"https://codeload.github.com/funvibe/funbit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funvibe%2Ffunbit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31967994,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binary","bitstring","erlang","erlang-otp","go","golang","golang-library","library","matching","pattern-matching"],"created_at":"2025-10-11T04:38:23.293Z","updated_at":"2026-04-18T12:04:03.475Z","avatar_url":"https://github.com/funvibe.png","language":"Go","readme":"# Funbit - Erlang/OTP Bit Syntax for Go\n\nFunbit is a Go library providing Erlang/OTP bit syntax compatibility for bitstring and binary data manipulation. It includes interfaces for constructing and pattern matching bitstrings.\n\n## Features\n\n- **Erlang Compatibility**: 1:1 mapping of Erlang bit syntax to a Go API.\n- **Bit-Level Operations**: Operates on a bit stream, not restricted to byte-aligned segments.\n- **Data Types**: Integer, float (16/32/64-bit), binary, bitstring, UTF-8/16/32.\n- **Dynamic Sizing**: Supports variables and arithmetic expressions in size fields (e.g., `total-6`).\n- **Unit Multipliers**: Allows size multiplication with `unit:N` (e.g., `32/float-unit:2` for a 64-bit double).\n- **Endianness Support**: Big, little, and native byte ordering.\n- **Compound Specifiers**: Supports combinations of specifiers (e.g., `32/big-unsigned-integer-unit:8`).\n- **String Literals in Patterns**: Allows constant string matching for protocol validation (e.g., `\"IHDR\":4/binary`).\n- **Builder API Pattern**: Operations are chained, with a single error check.\n- **Type Semantics**: Differentiates between integer and binary representations.\n- **Protocol Parsing**: Designed for parsing protocols such as IPv4, TCP, and PNG.\n- **Performance**: Optimized for construction and pattern matching.\n\n## Core Semantics\n\n### Binary vs. Integer Size\n```go\n// CRITICAL DIFFERENCE:\nfunbit.Integer(m, \u0026val, funbit.WithSize(32))  // 32 BITS\nfunbit.Binary(m, \u0026data, funbit.WithSize(32))  // 32 BYTES = 256 BITS!\n\n// For binary segments: WithSize(N) means N UNITS (default: bytes)\nfunbit.Binary(m, \u0026data, funbit.WithSize(4))   // 4 bytes\nfunbit.Binary(m, \u0026data, funbit.WithSize(32))  // 32 bytes\n```\n\n### Unit Multipliers for Dynamic Sizing\n```go\n// WITHOUT WithUnit(1): size*8 interpreted as BYTES, multiplied by 8!\nfunbit.Binary(m, \u0026data, funbit.WithDynamicSizeExpression(\"size*8\"))\n// size=5 → 5*8=40, but binary interprets as 40*8=320 bits!\n\n// WITH WithUnit(1): size*8 interpreted as exact BITS\nfunbit.Binary(m, \u0026data, funbit.WithDynamicSizeExpression(\"size*8\"), funbit.WithUnit(1))\n// size=5 → 5*8=40 bits exactly\n```\n\n### UTF Extraction Semantics\n```go\n// Erlang UTF supports BOTH approaches:\n\n// 1. String encoding (entire strings)\nfunbit.AddUTF8(builder, \"Hello\")  // Encodes full string\n\n// 2. Code point extraction (individual characters)\nfunbit.UTF8(matcher, \u0026codepoint)  // Single code point\n\n// 3. Binary extraction (for full strings)\nvar bytes []byte\nfunbit.RestBinary(matcher, \u0026bytes)\ntext := string(bytes)  // Full string\n```\n\n## Quick Start\n\n### Builder API Pattern\n\nFunbit uses a builder pattern for deferred error handling:\n\n```go\n// Chain operations, check error once\nbuilder := funbit.NewBuilder()\nfunbit.AddInteger(builder, 42, funbit.WithSize(8))\nfunbit.AddUTF8Codepoint(builder, 0x1F680) // rocket emoji\nfunbit.AddFloat(builder, 3.14, funbit.WithSize(32))\n\nbitstring, err := funbit.Build(builder) // Error checked once\nif err != nil {\n    return err\n}\n\n// Traditional approach:\n// if err := AddInteger(...); err != nil { return err }\n// if err := AddUTF8Codepoint(...); err != nil { return err }\n// if err := AddFloat(...); err != nil { return err }\n```\n\n**Characteristics:**\n- **Chainable**: `Add*` functions do not return errors.\n- **Efficient**: The first error halts processing; subsequent calls are ignored.\n- **Clean**: A single error check is performed at `Build()` time.\n- **Consistent**: The pattern is used throughout the API.\n\n### Installation\n\n```bash\ngo get github.com/funvibe/funbit\n```\n\n### Basic Construction and Matching\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"math/big\"\n    \"github.com/funvibe/funbit/pkg/funbit\"\n)\n\nfunc main() {\n    // Construction: \u003c\u003c42:8, \"hello\":5/binary\u003e\u003e\n    builder := funbit.NewBuilder()\n    funbit.AddInteger(builder, 42, funbit.WithSize(8))\n    funbit.AddBinary(builder, []byte(\"hello\"))\n    \n    bitstring, _ := funbit.Build(builder)\n    \n    // Pattern Matching: \u003c\u003cvalue:8, text:5/binary\u003e\u003e\n    matcher := funbit.NewMatcher()\n    var value int\n    var text []byte\n    \n    funbit.Integer(matcher, \u0026value, funbit.WithSize(8))\n    // CRITICAL: Binary size in BYTES! WithSize(5) = 5 bytes = 40 bits\n    funbit.Binary(matcher, \u0026text, funbit.WithSize(5)) // 5 bytes\n    \n    results, err := funbit.Match(matcher, bitstring)\n    if err == nil \u0026\u0026 len(results) \u003e 0 {\n        fmt.Printf(\"Value: %d, Text: %s\\n\", value, string(text))\n        // Output: Value: 42, Text: hello\n    }\n\n    // Big.Int support for huge integers\n    hugeInt := new(big.Int)\n    hugeInt.SetString(\"999999999999999999999999999999\", 10)\n    \n    builder2 := funbit.NewBuilder()\n    funbit.AddInteger(builder2, hugeInt, funbit.WithSize(256)) // 256-bit integer\n    \n    bitstring2, _ := funbit.Build(builder2)\n    fmt.Printf(\"Huge integer bitstring: %d bits\\n\", bitstring2.Length())\n}\n```\n\n## Core Concepts\n\n### Construction vs Pattern Matching\n\n**Construction** builds bitstrings from values:\n```go\nbuilder := funbit.NewBuilder()\nfunbit.AddInteger(builder, 1000, funbit.WithSize(16))\nfunbit.AddFloat(builder, 3.14, funbit.WithSize(32))\nbitstring, _ := funbit.Build(builder)\n```\n\n**Pattern Matching** extracts values from bitstrings:\n```go\nmatcher := funbit.NewMatcher()\nvar num int\nvar pi float32\nfunbit.Integer(matcher, \u0026num, funbit.WithSize(16))\nfunbit.Float(matcher, \u0026pi, funbit.WithSize(32))\nresults, _ := funbit.Match(matcher, bitstring)\n```\n\n### Type Semantics\n\nFunbit follows Erlang semantics where the default type is integer:\n\n```go\n// Construction\nfunbit.AddInteger(builder, 42, funbit.WithSize(8))     // Integer: displays as 42\nfunbit.AddBinary(builder, []byte(\"A\"), funbit.WithSize(1))  // Binary: displays as 'A' (1 byte)\n\n// Pattern Matching\nfunbit.Integer(matcher, \u0026num, funbit.WithSize(8))      // Extract as number: 42\nfunbit.Binary(matcher, \u0026char, funbit.WithSize(1))      // Extract as character: 'A' (1 byte)\n```\n\nThe interpretation of a bit sequence depends on the type specifier.\n\n## Advanced Features\n\n### Non-byte-aligned Bitstrings\n\nThe library supports bit-level operations that are not restricted to byte boundaries:\n\n```go\n// Build 7-bit value (not byte-aligned)\nbuilder := funbit.NewBuilder()\nfunbit.AddInteger(builder, 0b101, funbit.WithSize(3))   // 3 bits\nfunbit.AddInteger(builder, 0b1111, funbit.WithSize(4))  // 4 bits\n// Total: 7 bits (not a full byte)\n\nbitstring, _ := funbit.Build(builder)\n\n// Pattern matching bit-level\nmatcher := funbit.NewMatcher()\nvar part1, part2 int\n\nfunbit.Integer(matcher, \u0026part1, funbit.WithSize(3))  // Extract 3 bits\nfunbit.Integer(matcher, \u0026part2, funbit.WithSize(4))  // Extract 4 bits\n\nresults, _ := funbit.Match(matcher, bitstring)\n// part1 = 5 (0b101), part2 = 15 (0b1111)\n```\n\n### UTF Codepoint API\n\nThe API provides functions for handling single codepoints:\n\n```go\n// Encoding single codepoints\nbuilder := funbit.NewBuilder()\nfunbit.AddUTF8Codepoint(builder, 0x1F680)  // emoji\nfunbit.AddUTF16Codepoint(builder, 0x1F31F, funbit.WithEndianness(\"big\"))\nfunbit.AddUTF32Codepoint(builder, 65)  // 'A'\n\nbitstring, err := funbit.Build(builder)\nif err != nil {\n    // Handles invalid codepoints (e.g., surrogate pairs)\n    fmt.Printf(\"Error: %v\\n\", err)\n}\n\n// Extract as INTEGER (Erlang spec!)\nmatcher := funbit.NewMatcher()\nvar codepoint int\nfunbit.UTF8(matcher, \u0026codepoint)  // Returns 0x1F680 (integer)\n\nresults, _ := funbit.Match(matcher, bitstring)\n// codepoint = 128640 (0x1F680)\n```\n\n### Signed vs Unsigned Integers\n\n```go\n// Signed interpretation\nbuilder := funbit.NewBuilder()\nfunbit.AddInteger(builder, -50, funbit.WithSize(8), funbit.WithSigned(true))\n\n// Unsigned interpretation (default)\nfunbit.AddInteger(builder, 200, funbit.WithSize(8), funbit.WithSigned(false))\n\nbitstring, _ := funbit.Build(builder)\n\n// Pattern matching with signedness\nmatcher := funbit.NewMatcher()\nvar signedVal, unsignedVal int\n\nfunbit.Integer(matcher, \u0026signedVal, funbit.WithSize(8), funbit.WithSigned(true))\nfunbit.Integer(matcher, \u0026unsignedVal, funbit.WithSize(8), funbit.WithSigned(false))\n\nresults, _ := funbit.Match(matcher, bitstring)\n// signedVal = -50, unsignedVal = 200\n```\n\n### Dynamic Sizing with Expressions\n\n```go\n// Create matcher and register variables\nmatcher := funbit.NewMatcher()\nvar headerSize int = 32\nvar total int = 96\nfunbit.RegisterVariable(matcher, \"headerSize\", \u0026headerSize)\nfunbit.RegisterVariable(matcher, \"total\", \u0026total)\n\n// Use in expressions\nfunbit.AddBinary(builder, data, funbit.WithDynamicSizeExpression(\"total-headerSize\"))\n```\n\n### String Literals in Patterns\n\nString literals can be used in patterns for protocol field validation:\n\n```go\n// Validate PNG header: expect exactly \"IHDR\"\nmatcher := funbit.NewMatcher()\nvar length int\nexpectedType := \"IHDR\"\n\nfunbit.Integer(matcher, \u0026length, funbit.WithSize(32))\nfunbit.Binary(matcher, \u0026expectedType, funbit.WithSize(4)) // Must match \"IHDR\" (4 bytes)\n```\n\n### Endianness Control\n\n```go\n// Big-endian (default)\nfunbit.AddInteger(builder, 0x1234, funbit.WithSize(16), funbit.WithEndianness(\"big\"))\n\n// Little-endian  \nfunbit.AddInteger(builder, 0x1234, funbit.WithSize(16), funbit.WithEndianness(\"little\"))\n```\n\n### Unit Multipliers\n\nUnit multipliers allow size multiplication for precise control:\n\n```go\n// 32-bit float with unit:2 = 64-bit IEEE 754 double precision\nfunbit.AddFloat(builder, 3.14159265359, funbit.WithSize(32), funbit.WithUnit(2))\n\n// 8-bit size with unit:16 = 128 effective bits\nfunbit.AddInteger(builder, 8, funbit.WithSize(8), funbit.WithUnit(16))\n\n// Pattern matching with unit multipliers\nfunbit.Float(matcher, \u0026doubleValue, funbit.WithSize(32), funbit.WithUnit(2))\n```\n\n### Compound Specifiers\n\nCombine multiple specifiers for complex data layouts:\n\n```go\n// 32/big-unsigned-integer-unit:8\nfunbit.AddInteger(builder, 0xDEADBEEF,\n    funbit.WithSize(32),\n    funbit.WithEndianness(\"big\"),\n    funbit.WithUnit(8))\n\n// 16/little-unsigned-integer\nfunbit.AddInteger(builder, 0x1234,\n    funbit.WithSize(16),\n    funbit.WithEndianness(\"little\"))\n```\n\n### Bit-Level Precision\n\n```go\n// Individual flag bits\nfunbit.AddInteger(builder, 1, funbit.WithSize(1))  // Single bit\nfunbit.AddInteger(builder, 0, funbit.WithSize(1))  // Another bit\nfunbit.AddInteger(builder, 3, funbit.WithSize(2))  // 2-bit value\n```\n\n## Examples\n\n### TCP Header Parsing\n\n```go\nbuilder := funbit.NewBuilder()\nfunbit.AddInteger(builder, 0x1234, funbit.WithSize(16))    // Source port\nfunbit.AddInteger(builder, 0x5678, funbit.WithSize(16))    // Dest port\nfunbit.AddInteger(builder, 1, funbit.WithSize(1))          // URG flag\nfunbit.AddInteger(builder, 0, funbit.WithSize(1))          // ACK flag\n// ... more flags\nfunbit.AddBinary(builder, []byte(\"payload\"))\n\n// Pattern matching extracts all fields with proper types\n```\n\n### PNG Header Validation\n\n```go\n// Pattern: \u003c\u003clength:32, \"IHDR\":4/binary, width:32, height:32\u003e\u003e\nmatcher := funbit.NewMatcher()\nvar length, width, height int\nexpectedChunk := \"IHDR\"\n\nfunbit.Integer(matcher, \u0026length, funbit.WithSize(32))\nfunbit.Binary(matcher, \u0026expectedChunk, funbit.WithSize(4))  // Validates \"IHDR\" (4 bytes)\nfunbit.Integer(matcher, \u0026width, funbit.WithSize(32))\nfunbit.Integer(matcher, \u0026height, funbit.WithSize(32))\n```\n\n## Usage Guidelines\n\n### 1. Understand Type Semantics\n- Use `funbit.Integer()` for numeric values (displays as numbers)\n- Use `funbit.Binary()` for text/character data (displays as characters)\n- Default type is **integer**, not binary\n\n### 2. Handle Dynamic Sizes Properly\n```go\n// Register all variables before use\nfunbit.RegisterVariable(\"size\", 32)\nfunbit.RegisterVariable(\"total\", 128)\n\n// Use expressions for complex sizing\nfunbit.WithDynamicSizeExpression(\"total-size-8\")\n```\n\n### 3. Validate Protocol Constants\n```go\n// Use string literals to validate protocol headers\nexpectedType := \"IHDR\"\nfunbit.Binary(matcher, \u0026expectedType, funbit.WithSize(4))  // 4 bytes = \"IHDR\"\n```\n\n### 4. Use Unit Multipliers for Precision\n```go\n// For IEEE 754 double precision floats\nfunbit.AddFloat(builder, value, funbit.WithSize(32), funbit.WithUnit(2))  // 64-bit\n\n// For size fields that represent bit counts\nfunbit.AddInteger(builder, 8, funbit.WithSize(8), funbit.WithUnit(16))    // 8*16 bits\n```\n\n### 5. Combine Specifiers for Complex Layouts\n```go\n// Full compound specifier\nfunbit.AddInteger(builder, value,\n    funbit.WithSize(32),\n    funbit.WithEndianness(\"big\"),\n    funbit.WithUnit(8))\n```\n\n### 6. Endianness Format\n```go\n// Use short forms\nfunbit.WithEndianness(\"big\")     // Supported\nfunbit.WithEndianness(\"little\")  // Supported  \nfunbit.WithEndianness(\"native\")  // Supported\n```\n\n### 7. Pattern Size Validation\nFunbit automatically validates pattern sizes unless:\n- Pattern contains rest patterns (`funbit.RestBinary()`)\n- Pattern contains dynamic sizes\n- Pattern contains string literals (for validation)\n- Pattern contains unit multipliers (calculated dynamically)\n\n## Erlang to Funbit Syntax Reference\n\n| Erlang Syntax | Funbit Equivalent | Description |\n|---------------|-------------------|-------------|\n| `\u003c\u003c42:8\u003e\u003e` | `funbit.AddInteger(b, 42, funbit.WithSize(8))` | 8-bit integer |\n| `\u003c\u003c42:8/big\u003e\u003e` | `funbit.AddInteger(b, 42, funbit.WithSize(8), funbit.WithEndianness(\"big\"))` | Big-endian integer |\n| `\u003c\u003c999999999999999999999:256\u003e\u003e` | `hugeInt := new(big.Int); hugeInt.SetString(\"999999999999999999999\", 10); funbit.AddInteger(b, hugeInt, funbit.WithSize(256))` | Arbitrary-precision integer |\n| `\u003c\u003c3.14:32/float\u003e\u003e` | `funbit.AddFloat(b, 3.14, funbit.WithSize(32))` | 32-bit float |\n| `\u003c\u003c\"hello world\"/binary\u003e\u003e` | `funbit.AddBinary(b, []byte(\"hello world\"))` | Binary data (full) |\n| `\u003c\u003c\"hello world\":5/binary\u003e\u003e` | `funbit.AddBinary(b, []byte(\"hello world\"), funbit.WithSize(5))` | Binary data (truncated to 5 bytes: \"hello\") |\n| `\u003c\u003cSize:8, Data:Size/binary\u003e\u003e` | `funbit.Integer(m, \u0026size, funbit.WithSize(8))`\u003cbr\u003e`funbit.Binary(m, \u0026data, funbit.WithDynamicSizeExpression(\"size\"))` | Dynamic sizing |\n| `\u003c\u003cValue:16/unit:8\u003e\u003e` | `funbit.AddInteger(b, value, funbit.WithSize(16), funbit.WithUnit(8))` | Unit multiplier |\n| `\u003c\u003cCodepoint/utf8\u003e\u003e` | `funbit.AddUTF8Codepoint(b, codepoint)` | UTF-8 codepoint |\n| `\u003c\u003c\"text\"/utf8\u003e\u003e` | `funbit.AddUTF8(b, \"text\")` | UTF-8 string |\n| `\u003c\u003c-50:8/signed\u003e\u003e` | `funbit.AddInteger(b, -50, funbit.WithSize(8), funbit.WithSigned(true))` | Signed integer |\n| `\u003c\u003cRest/binary\u003e\u003e` | `funbit.RestBinary(m, \u0026rest)` | Rest pattern |\n| `\u003c\u003c1:3, 15:4\u003e\u003e` | `funbit.AddInteger(b, 1, funbit.WithSize(3))`\u003cbr\u003e`funbit.AddInteger(b, 15, funbit.WithSize(4))` | Non-byte-aligned |\n\n**API Differences from Erlang:**\n- Funbit uses an explicit builder pattern vs Erlang's literal syntax.\n- Funbit requires variable registration for dynamic sizes.\n- Funbit supports method chaining and error accumulation.\n- Funbit provides stronger type safety with Go's type system.\n- Funbit supports arbitrary-precision integers via `*big.Int` for huge numbers\n\n## 🔢 Arbitrary-Precision Integer Support\n\nFunbit now supports `*big.Int` for handling arbitrarily large integers without precision loss:\n\n```go\nimport \"math/big\"\n\n// Create a huge integer\nhugeInt := new(big.Int)\nhugeInt.SetString(\"999999999999999999999999999999\", 10) // 30 digits\n\n// Add to bitstring with appropriate size\nbuilder := funbit.NewBuilder()\nfunbit.AddInteger(builder, hugeInt, funbit.WithSize(256)) // 256-bit integer\n\nbitstring, err := funbit.Build(builder)\nif err != nil {\n    log.Fatalf(\"Failed to build: %v\", err)\n}\n\n// Pattern matching extracts as *big.Int\nmatcher := funbit.NewMatcher()\nvar extracted *big.Int\nfunbit.Integer(matcher, \u0026extracted, funbit.WithSize(256))\n\nresults, err := funbit.Match(matcher, bitstring)\nif err == nil \u0026\u0026 len(results) \u003e 0 {\n    fmt.Printf(\"Extracted: %s\\n\", extracted.String()) // Full precision\n}\n```\n\n**Benefits:**\n- **No Precision Loss**: Handle numbers larger than `float64` can represent\n- **Exact Arithmetic**: Perfect for cryptographic applications, large IDs, etc.\n- **Automatic Detection**: Funbit automatically uses `*big.Int` when needed\n- **Backward Compatible**: Regular `int` values continue to work as before\n\n**Use Cases:**\n- Cryptographic keys and hashes\n- Large database IDs\n- Financial calculations with high precision\n- Scientific computing with large numbers\n- Protocol fields with arbitrary size\n\n## Performance\n\n- **Construction**: O(n) where n is number of segments\n- **Pattern Matching**: O(n) where n is number of segments  \n- **Memory**: Bitstrings are immutable and memory-efficient\n- **Threading**: Thread-safe for concurrent reads; builders are not thread-safe.\n\n## Integration with Runtimes\n\nWhen integrating with language runtimes (like Lua, JavaScript):\n\n```go\n// For integers extracted from patterns\nif intValue \u003e= 0 \u0026\u0026 intValue \u003c= 255 {\n    // In mixed binary context, might display as character\n    // In pure integer context, display as number\n}\n\n// For binary data\nstring(binaryData) // Always display as characters\n```\n\n## Additional Examples\n\nRefer to `funbit/examples/public_api_example.go` for examples covering:\n- Basic construction and matching\n- Data types and specifiers  \n- Endianness support\n- Dynamic sizing\n- String literals in patterns\n- Complex protocol parsing\n- Unit multipliers\n- Compound specifiers\n- Advanced float handling\n- Type semantics\n- Integration patterns\n\n## Contributing\n\nContributions are accepted.\n\n## License\n\nMIT License. See the LICENSE file for details.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunvibe%2Ffunbit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffunvibe%2Ffunbit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunvibe%2Ffunbit/lists"}