binary 0.1.3

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 60

binary

Utilities for working with binary data and bit manipulation in Dart.

Pub Build Status Coverage Status documentation

NOTE: Unless otherwise noted, all functionality is based around treating bits as little endian, that is in a 32-bit integer the leftmost bit is 31 and the rightmost bit is 0

Overview

This library supports an Integral data type for fluent bit manipulation:

print(uint8.toBinaryPadded(196)); // '11000100'

Because of Dart's ability to do advanced inlining in both the Dart VM and dart2js, this library should perform well and be extremely easy to use for most use cases. For example, it's used in an arm7_tdmi emulator.

Usage

This library has a combination of top-level methods, and instance methods of pre-defined Integral data types (see below). For example there are two ways to clear (set to 0) a bit:

// Sets the 0th bit in an (int) bits to 0
bits = clearBit(bits, 0)

However, this will not do range validation. Use Integral#clearBit:

// Sets the 0th bit in a uint32 to 0.
// In dev-mode, if either bits or `n` is out of range it throws.
bits = uint32.clearBit(bits, 0);

Integral data types

  • bit
  • int4
  • int8
  • int16
  • int32
  • int64
  • int128
  • uint4
  • uint8
  • uint16
  • uint32
  • uint64
  • uint128

Learning more

See the dartdocs for more about the API.

0.1.3

  • Added arithmeticShiftRight

0.1.2

  • Moved into a standalone repository (outside of gba.dart).
  • Added signExtend as a method to Integral.
  • Added areSet.
  • Added msb.

0.1.1

  • Added signExtend

0.1.0

  • Fixed a bug where int128 and uint128 only had a length of 64.

0.0.4

  • Updated the documentation and README.

0.0.3

  • Added isZero.

0.0.2

  • Added isNegative, hasCarryBit, doesAddOverflow, doesSubOverflow, mask.
  • Added parseBits.

0.0.1

  • Add top-level isSet and isClear, Integral#isSet, Integral#isClear.
  • Add checked-mode range checks to bitChunk and bitRange.
  • Fix a bug in the implementation of bitChunk and bitRange.
  • Added a top-level fromBits and Integral#fromBits

0.0.0

  • Initial commit, feedback welcome!

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  binary: "^0.1.3"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:binary/binary.dart';
        
Version Uploaded Documentation Archive
0.1.3 May 15, 2017 Go to the documentation of binary 0.1.3 Download binary 0.1.3 archive
0.1.2 Mar 19, 2017 Go to the documentation of binary 0.1.2 Download binary 0.1.2 archive
0.1.1 Mar 18, 2017 Go to the documentation of binary 0.1.1 Download binary 0.1.1 archive
0.1.0 Feb 19, 2017 Go to the documentation of binary 0.1.0 Download binary 0.1.0 archive
0.0.4 Feb 11, 2017 Go to the documentation of binary 0.0.4 Download binary 0.0.4 archive
0.0.3 Feb 9, 2017 Go to the documentation of binary 0.0.3 Download binary 0.0.3 archive
0.0.2 Feb 9, 2017 Go to the documentation of binary 0.0.2 Download binary 0.0.2 archive
0.0.1 Feb 8, 2017 Go to the documentation of binary 0.0.1 Download binary 0.0.1 archive
0.0.0 Feb 7, 2017 Go to the documentation of binary 0.0.0 Download binary 0.0.0 archive

Analysis

This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
21 / 100
Health:
Code health derived from static analysis. [more]
100 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
60

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:binary/binary.dart.

Suggestions

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use binary.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.23.0-dev.1.0 <2.0.0
meta ^1.0.4 1.1.2
Dev dependencies
presubmit 0.0.2
test ^0.12.18+1