Giter VIP home page Giter VIP logo

scodec-bits's Introduction

scodec-bits

Provides persistent datatypes for working with bits and bytes.

Design Constraints

  • No dependencies on other libraries in order to be applicable to as many projects as possible.

Administrative

This project is licensed under a 3-clause BSD license.

The scodec mailing list contains release announcements and is generally a good place to go for help. Also consider using the scodec tag on StackOverflow.

People are expected to follow the Typelevel Code of Conduct when discussing scodec on the Github page, Gitter channel, mailing list, or other venues.

Concerns or issues can be sent to Michael Pilquist ([email protected]) or to Typelevel.

Introduction

There are two fundamental data structures provided:

Both datatypes provide collection like functionality, although neither directly implement the Scala collection library traits. Both are implemented as binary trees where each node is either a leaf node containing bits/bytes or is an inner node containing an operation on other trees (e.g., append). As a result, many operations are implemented in logarithmic time with respect to the depth of the tree.

Both strict and lazy constructors are provided. Of particular interest are the methods that work with Java NIO sources like java.nio.channels.ReadableByteChannel and java.nio.channels.FileChannel, which allow efficient, lazy access and manipulation of bits and bytes from a variety of sources.

Hexadecimal and binary string literals are supported via the hex and bin string interpolators. For example:

val x: ByteVector = hex"deadbeef"
val y: BitVector = bin"00101101010010101"

Base conversions to and from strings are supported. Binary, hexadecimal, and base 64 conversions are supported. Each have a default alphabet but support alternative alphabets as well as user defined alphabets.

For more information, see the API documentation.

For a combinator based approach to encoding values to/from binary, see the companion project scodec.

Getting Binaries

See the releases page on the website.

Building

This project uses sbt and requires node.js to be installed in order to run Scala.js tests. To build, run sbt publish-local.

scodec-bits's People

Contributors

aloiscochard avatar bryce-anderson avatar ceedubs avatar coltfred avatar mdedetrich avatar mpilquist avatar pchiusano avatar rossabaker avatar vptheron avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.