bit_pattern 0.0.1

  • Installing
  • Versions
  • 22


Build Status

Bit sequence matchers for building emulators in Dart.

Creating a pattern

Patterns can be created from a sequence of 0s, 1s and variable length chunks.

// Create a pattern that matches any integer whose most significant byte is
// 0x6 and whose least significant byte is anything.
var pattern = new BitPattern([0, 1, 1, 0, v(4, 'lsb')]); 

The pattern can be used to determine whether an integer uses an equivalent bit sequence.

pattern.matches(0x60); // == true
pattern.matches(0x6F); // == true
pattern.matches(0x50); // == false

Patterns can be put into groups to simplify matching multiple patterns against an integer using a PatternGroup.

var pattern0x1 = new BitPattern([0, 0, 0, 1]);
var pattern0xF = new BitPattern([1, 1, 1, 1]);
var patternGroup = new BitPatternGroup([pattern0x1, pattern0xF]);

patternGroup.match(0x1) == pattern0x1; // true
patternGroup.match(0xF) == pattern0xF; // true
patternGroup.match(0x6) == null;     // true

If there are multiple BitPatterns in a PatternGroup that match some integer, the group with the fewest number of non-variable bits is returned. If two or more matched patterns have an identical number of non-variable bits, then these two patterns are incompatible and a BitPatternException is raised.

var pattern0xE = new BitPattern([0, 1, 1, 1]);
var patternAny1 = new BitPattern([v(4, 'any1')]);
var patternAny2 = new BitPattern([v(4, 'any2')]);
var patternGroup = new BitPatternGroup([patternAny1, pattern0xE, patternAny2]);

patternGroup.match(0xE) == pattern0xE; // true
patternGroup.match(0xF) == patternAny2; // error! Both patternAny1 and patternAny2 match!

Use this package as a library

1. Depend on it

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

  bit_pattern: "^0.0.1"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

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

3. Import it

Now in your Dart code, you can use:

      import 'package:bit_pattern/bit_pattern.dart';
Version Uploaded Documentation Archive
0.0.1 May 22, 2017 Go to the documentation of bit_pattern 0.0.1 Download bit_pattern 0.0.1 archive
0.0.4-alpha May 27, 2017 Go to the documentation of bit_pattern 0.0.4-alpha Download bit_pattern 0.0.4-alpha archive
0.0.3-alpha May 23, 2017 Go to the documentation of bit_pattern 0.0.3-alpha Download bit_pattern 0.0.3-alpha archive
0.0.2-alpha May 22, 2017 Go to the documentation of bit_pattern 0.0.2-alpha Download bit_pattern 0.0.2-alpha archive


We analyzed this package on Jun 18, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.60.0
  • pana: 0.11.3


Describes how popular the package is relative to other packages. [more]
0 / 100
Code health derived from static analysis. [more]
40 / 100
Reflects how tidy and up-to-date the package is. [more]
52 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: unsure

Error(s) prevent platform classification:

Error(s) in lib/bit_pattern.dart: Target of URI doesn't exist: 'package:collection/collection.dart'.


  • Fix platform conflicts.

    Error(s) prevent platform classification:

    Error(s) in lib/bit_pattern.dart: Target of URI doesn't exist: 'package:collection/collection.dart'.

  • Running dartdoc failed.

    Make sure dartdoc runs without any issues.

  • Maintain

    Changelog entries help clients to follow the progress in your code.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 3 errors.

    Make sure that the imported libraries are not in conflict. Error(s) in lib/bit_pattern.dart: Target of URI doesn't exist: 'package:collection/collection.dart'.

  • Package is getting outdated.

    The package was released 55 weeks ago.

  • 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 bit_pattern.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.22.0 <2.0.0
binary ^0.1.3 0.1.3
meta ^1.0.5 1.1.5
Dev dependencies
presubmit 0.0.2
test ^0.12.18+1