4.0.0
Stable release!
Important
Version 4.0.0 has a large set of breaking changes, including removing the
vast majority of extension methods and boxed classes, in favor of using the
newer extension types feature in Dart. I would be opening to adding back
some deprecated methods, or a lib/compat.dart file if there is demand;
please file an issue if you need this.
New features:
- Added
viewOrCopyAsBytes. - Added
BytesBuilderExtension.
Read the release notes below for a summary of changes.
4.0.0-beta
- Update Dart SDK to
^3.5.0.
4.0.0-alpha+7
- Added
<Int>.lsb. - Removed bit-operations from
IntExtension; they are too easy to use
incorrectly in the JS VM.
4.0.0-alpha+6
- Just kidding,
checkRangewill return{{Int}}if no error is thrown.
4.0.0-alpha+5
<Int>.checkRangereturns theintif no error was thrown (instead of
void).
4.0.0-alpha+4
- Actually publish the contents of
4.0.0-alpha+3.
4.0.0-alpha+3
New features:
- Added
<Int>.maxIntand<Int>.minIntas static (int) constants.
4.0.0-alpha+2
Breaking changes:
<FixedInt>, which was pointless, is now justint. That means that any
fixed integer representation can be provided somewhere anintis expected,
which cuts down on boilerplate without much value.
4.0.0-alpha+1
New features:
-
Added
BitList, a compactList<bool>implementation that stores every
element as a single bit, with implementations that are fixed-size and
growable. -
Added
<FixedInt>.zeroand<FixedInt>.oneas static constants. -
Added
collectBytes(), a utility to convert aStream<List<int>>into a
Uint8List.
Breaking changes:
-
Replaced
<FixedInt>.bitswith<FixedInt>.toBitList():- final bits = Int8(0).bits; + final bits = Int8(0).toBitList();
4.0.0-alpha
New features:
Lots and lots. It will be easier to just read the API documentation.
Breaking changes:
Basically everything. The entire API has been restructured to use extension
types, and some APIs removed entirely that were either not well-thought out
(oops) or were unnecessary:
-
Integral, which was a base type for defining integers, has been removed in
favor of a helper class,IntDescriptor, which is used to define new integer
types, and acts sort of a meta type or poor man's macro for defining features:- class Int4 extends Integral<Int4> { - Int4(int value) : super.checked(value, signed: true, size: 4); - - @override - Int4 wrapSafeValue(int value) => Int4(value); - } + extension type const Int4._(int _) implements FixedInt { + static const _descriptor = _IntDescriptor<Int8>.signed( + Int4.fromUnchecked, + width: 4, + max: 7, + ); + + factory Int4(int v) => _descriptor.fit(v); + + // ... + }
In practice, it is much more difficult to implement a custom type, as many
methods have to be hand-written, but it is also a much better future-proof
approach. In the near-term, it's possible we could expose the code generator
used by this package internally as a tool for others to use, and longer-term
Dart macros can be used to simplify this
process for users. -
Fixed-size integers still exist, but with an updated API. Replacements are a
follows:.bitChunk(l, r)->.chunk(l, [s?]).bitRange(l, r)->.slice(l, [r?]).bitsSet->.countOnes().clearBit(n)->.setNthBit(n, false).getBit(n)->.nthBit(n)oroperator [n].replaceBitRange(l, r, b)->.replace(l, r?, b).rotateLeftShift(n)->.rotateLeft(n).rotateRightShift(n)->.rotateRight(n).setBit(n)->.setNthBit(n).signExtend(n)-> removed..sizehas been removed in favor of a static.width; as extension types
are non-virtual..toggleBit(n)->.toggleNthBit(n).value->.toInt()
-
The extension methods
BinaryIntwere removed. Instead, use the extension
types directly. A small subset of helper methods are available on
IntExtensionbut have little in common with the previous API (mostly
convenience methods). -
Every other extension method set was removed.
Full Changelog: v2.0.0...v4.0.0