pro_binary 4.0.0
pro_binary: ^4.0.0 copied to clipboard
Efficient binary serialization library for Dart. Encodes and decodes various data types.
4.0.0 #
BREAKING CHANGES:
- BinaryReader: removed
reset()method — useseek(0)instead
New Features:
- BinaryReader: added
rebind(Uint8List)— rebinds the reader to a new buffer without allocating a new instance (useful for streaming scenarios) - BinaryWriter: added
seek(int position)— sets the write position to the specified byte offset (useful for backtracking and overwriting data mid-stream) - BinaryWriter: added
writeUint8At(int position, int value)— writes a byte at the specified position without changing the current write position - BinaryWriter:
writeVarStringnow usesseekinternally for VarInt length rewriting - Stream API: added
StreamBinaryReader— chunk-based reader for asynchronous streaming data with bookmark/rollback/commit transactional model - Stream API: added
BinaryStreamTransformer<T>— abstractStreamTransformerfor parsing binary messages from streams with automaticNotEnoughDataExceptionhandling - Stream API: added
NotEnoughDataException— carriesrequired/availablebyte counts for debugging incomplete data scenarios
Fixes:
- BinaryReader: added bounds check to
peekByte()— now throwsRangeErrorconsistently like other read methods
Tests: Improved all tests
3.2.0 #
BREAKING CHANGES:
- BinaryWriterPool: renamed
_defaultBufferSize→_initialBufferSizer(and parameterdefaultBufferSize→initialBufferSizerinacquire()andwithWriter())
New Features:
- BinaryWriterPool: added
_discardedPoolFullcounter — tracks writers discarded due to pool full (max 32) - BinaryWriter: added
_varIntSize(int value)— helper function for VarInt size calculation (switch expression) - BinaryReader: added
peekByte()— returns byte at current position without advancing offset - BinaryReader: added
BinaryReader.fromList(List<int>)— convenient constructor forList<int>
Fixes:
- BinaryWriterPool: added validation for
initialBufferSizerinacquire()— throwsRangeErrorfor invalid size - BinaryWriterPool:
_initializeBuffer()now resets_isInPool = false, correcttakeBytes()→release()flow for pooled writers - BinaryWriterPool:
clear()now resets_isInPoolfor pooled writers - BinaryReader/BinaryWriter: removed unnecessary
latefrom_ReaderStateand_WriterState(offset, capacity, list) - BinaryReader: removed redundant bounds check in
peekBytes()(already guarded by_checkBounds)
Refactoring:
- _WriterState: renamed
_validated→_fromSize - string_utils.dart: replaced JSDoc tags
@param/@returnwith Dart style (Parameters:/Returns:)
Tests:
- Added tests for pool statistics, edge cases takeBytes/reset/release
3.1.0 #
- feat: Added
BinaryWriterPool.withWriter()for safer and more concise object pool usage. - feat: Added modern API features for a more idiomatic experience:
BinaryReader: Addedoperator []for absolute byte access (e.g.,reader[0]).BinaryReader: Addedcall()method for shorthand byte reading (e.g.,reader(10)).BinaryWriter: Addedcall()method for shorthand byte writing (e.g.,writer([1, 2, 3])).
- performance: Optimized
writeVarStringwith a high-performance one-pass "optimistic shift" algorithm (~30% faster). - performance: Unrolled
readVarUintloop for the first 3 bytes, resulting in ~25% speedup in AOT mode. - performance: Applied Fast Path / Slow Path optimization to buffer expansion logic for better inlining.
- improvement: Enhanced
BinaryWriterPool.clear()with explicit buffer reference discarding to assist GC. - fix: Added missing
ensureSizecheck inBinaryWriterPool.acquireto guarantee buffer capacity when reusing writers. - improvement: Updated lint rules to
pro_lints/recommended.yamland resolved related lint issues. - deps: Updated
pro_lints,test, andmetadependencies to latest versions. - test: Refactored pool benchmarks for better accuracy and reliability.
- docs: Fixed minor typos and improved documentation for
BinaryWriterPool. - docs: Complete README overhaul with a focus on recipes and technical clarity.
3.0.0 #
Improvements:
-
feat: New methods and properties
BinaryWriterPoolfor reusingBinaryWriterinstancesgetUtf8Length(String)to calculate UTF-8 byte length without encodingwriteVarString(String)andreadVarString()for variable-length string encodingwriteBoolandreadBoolmethods for boolean valueswriteVarUintandreadVarUintfor variable-length unsigned integerswriteVarIntandreadVarIntfor variable-length signed integerswriteVarBytesandreadVarBytesfor variable-length byte arrays- Navigation methods in
BinaryReader:peekBytes(),skip(),seek(),rewind(), andreset()
-
docs: Comprehensive documentation overhaul
- Added detailed API documentation with usage examples for all methods
- Documented
writeVarString(),readVarString(), andgetUtf8Length() - Included performance notes and best practices
- Added inline comments explaining complex encoding algorithms
-
test: Expanded test suite
- Coverage for all new methods and edge cases
- Performance benchmarks for encoding/decoding functions
- Validation tests for UTF-8 handling and error scenarios
-
improvement: Refactored internal codebase
- Improved modularity and readability
- Enhanced error handling with descriptive messages
- Optimized buffer management for better performance
-
fix: Resolved known issues
2.2.0 #
test: Added integration tests for new error handling features deps: Update internal dependencies to latest versions
2.1.0 #
- feat: Added detailed error messages with context (offset, available bytes)
- feat: Added
toBytes()method inBinaryWriter(returns buffer without reset) - feat: Added
reset()method inBinaryWriter(resets without returning data) - feat: Added
allowMalformedparameter toreadStringinBinaryReader - improvement: Increased performance of read/write operations
- improvement: Optimized internal buffer management in
BinaryWriter - improvement: Added validation for all boundary conditions
- test: Added new tests for boundary checks and new methods
- docs: Updated documentation with better examples and error handling
2.0.0 #
- Update dependencies
- sdk: ^3.6.0
1.1.1 #
- fix: warnings
1.1.0 #
-
fix: Increased test coverage, providing more comprehensive validation for edge cases.
-
performance: Optimized buffer management to reduce memory reallocations and improve efficiency.
-
docs: Updated documentation to cover new properties and methods, including additional examples.
-
Writer:
- feat: Added
bytesWrittenproperty to track the total number of bytes written to the buffer. - feat: Introduced
initialBufferSizeparameter in the constructor, allowing configuration of the initial buffer size for optimized memory usage. - improvement: Enhanced memory management, with the buffer now resizing by doubling in size when capacity is reached to reduce frequent resizing.
- feat: Added
-
Reader:
- feat: Added
bytesReadproperty to monitor the total number of bytes read from the buffer. - feat: Introduced
resetmethod, allowing users to reset the reading position to the start of the buffer for convenient re-reading.
- feat: Added
1.0.2 #
- docs: Updated documentation.
1.0.1 #
- docs: Updated documentation.
- feat: Added
exampledirectory with basic usage examples.
1.0.0 #
- Initial release.