bsdiff 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 83

BSDiff #

pub package

Binary diff/patch algorithm based on bsdiff 4.3 by Colin Percival. It's very effective at compressesing incremental changes in binaries.

This implementation has the following differences from Colin's code, to make it easier to read and apply patches in Java and Objective C:

  • Using gzip instead of bzip2 because gzip is included in JDK by default
  • Using big- instead of little-endian serialization to simplify Java code
  • Using two's complement instead of high-bit coding for negatives numbers

Usage #

To use this package, add bsdiff as a dependency in your pubspec.yaml file.

Example #

Import the library via

import 'package:bsdiff/bsdiff.dart';

Then use the bsdiff and bspatch Dart functions in your code. To see how this is done, check out the example app.

0.1.0 #

  • Initial Open Source release.


// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Example script to illustrate how to use the bsdiff package to generate and apply patches.

import 'dart:typed_data';

import 'package:bsdiff/bsdiff.dart';

void main() async {
  final Uint8List originalData = Uint8List.fromList(List.generate(1000, (index) => index));
  final Uint8List modifiedData = Uint8List.fromList(List.generate(2000, (index) => 2 * index));

  print('Original data size ${originalData.length} bytes');
  print('Modified data size ${modifiedData.length} bytes');

  final Uint8List generatedPatch = bsdiff(originalData, modifiedData);
  final Uint8List restoredData = bspatch(originalData, generatedPatch);

  print('Generated patch is ${generatedPatch.length} bytes');
  print('Restored data size ${restoredData.length} bytes');

Use this package as a library

1. Depend on it

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

  bsdiff: ^0.1.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:

import 'package:bsdiff/bsdiff.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4

Health issues and suggestions

Document public APIs. (-1 points)

3 out of 3 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/bsdiff.dart.

Run dartfmt to format lib/bsdiff.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.1-dev.2.0 <3.0.0
Dev dependencies
test ^1.3.4