Git Product home page Git Product logo

bitmap-integers's Introduction

bitmap-integers

Small utility module to convert between integer representations of bitmaps and arrays.

NPM License

Build Status Dependencies Dev dependencies

Usage

const bitmap = require('bitmap-integers');

Array to Value

Integer arrays

You can pass in an array of integers you want to set

bitmap.fromIntegerArray([1]);     // 1
bitmap.fromIntegerArray([2]);     // 2
bitmap.fromIntegerArray([1,2]);   // 3
bitmap.fromIntegerArray([3]);     // 4
bitmap.fromIntegerArray([1,3]);   // 5
bitmap.fromIntegerArray([2,3]);   // 6
bitmap.fromIntegerArray([1,2,3]); // 7

Little endian boolean array

You can pass in an array of booleans in LE form

bitmap.fromBooleanArrayLE([true]);                 // 1
bitmap.fromBooleanArrayLE([false, true]);          // 2
bitmap.fromBooleanArrayLE([true,  true]);          // 3
bitmap.fromBooleanArrayLE([false, false, true]);   // 4
bitmap.fromBooleanArrayLE([true,  false, true]);   // 5
bitmap.fromBooleanArrayLE([false, true,  true]);   // 6
bitmap.fromBooleanArrayLE([true,  true,  true]);   // 7

Big endian boolean array

You can pass in an array of booleans in BE form

bitmap.fromBooleanArrayBE([true]);                // 1
bitmap.fromBooleanArrayBE([true, false]);         // 2
bitmap.fromBooleanArrayBE([true, true]);          // 3
bitmap.fromBooleanArrayBE([true, false, false]);  // 4
bitmap.fromBooleanArrayBE([true, false, true]);   // 5
bitmap.fromBooleanArrayBE([true, true,  false]);  // 6
bitmap.fromBooleanArrayBE([true, true,  true]);   // 7

Value to Array

Integer arrays

You can get an integer array from a value

bitmap.toIntegerArray(1); // [1]    
bitmap.toIntegerArray(2); // [2]    
bitmap.toIntegerArray(3); // [1,2]  
bitmap.toIntegerArray(4); // [3]    
bitmap.toIntegerArray(5); // [1,3]  
bitmap.toIntegerArray(6); // [2,3]  
bitmap.toIntegerArray(7); // [1,2,3]

Little endian boolean array

You can get an array of booleans in LE form

bitmap.toBooleanArrayLE(1); // [true]              
bitmap.toBooleanArrayLE(2); // [false, true]       
bitmap.toBooleanArrayLE(3); // [true,  true]       
bitmap.toBooleanArrayLE(4); // [false, false, true]
bitmap.toBooleanArrayLE(5); // [true,  false, true]
bitmap.toBooleanArrayLE(6); // [false, true,  true]
bitmap.toBooleanArrayLE(7); // [true,  true,  true]

Big endian boolean array

You can get an array of booleans in BE form

bitmap.toBooleanArrayBE(1); // [true]              
bitmap.toBooleanArrayBE(2); // [true, false]       
bitmap.toBooleanArrayBE(3); // [true, true]        
bitmap.toBooleanArrayBE(4); // [true, false, false]
bitmap.toBooleanArrayBE(5); // [true, false, true] 
bitmap.toBooleanArrayBE(6); // [true, true,  false]
bitmap.toBooleanArrayBE(7); // [true, true,  true] 

Testing

npm test

bitmap-integers's People

Contributors

deancouch avatar rprieto avatar anklos 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.