GithubHelp home page GithubHelp logo

jsimpson / binary_reader Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 21 KB

A Deno module and helper class that provides an easy way to read different types from a binary array buffer.

License: MIT License

TypeScript 100.00%
typescript typescript-library binary binary-reader deno

binary_reader's Introduction

Binary Reader

A Deno module helper class that wraps around DataView to provide an easy way to read different types from a binary array buffer while maintaining the current buffer position.

Usage

import { BinaryReader } from "https://deno.land/x/[email protected]/mod.ts";

const filename = "some-file.bin";
const file = Deno.openSync(filename);
const buffer = Deno.readAllSync(file);
Deno.close(file.rid);

const binaryReader = new BinaryReader(buffer);
let data = binaryReader.readUint8();

binary_reader's People

Contributors

jsimpson avatar thatblockypenguin avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

binary_reader's Issues

TS2729 [ERROR]: Property 'buffer' is used before its initialization.

When using binary_reader, I got the following error from TypeScript:

error: TS2729 [ERROR]: Property 'buffer' is used before its initialization.
    this.buffer.buffer,
         ~~~~~~
    at https://deno.land/x/[email protected]/binary_reader.ts:3:10      

    'buffer' is declared here.
      constructor(private buffer: Uint8Array) {}
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~
        at https://deno.land/x/[email protected]/binary_reader.ts:9:15

TS2729 [ERROR]: Property 'buffer' is used before its initialization.
    this.buffer.byteOffset,
         ~~~~~~
    at https://deno.land/x/[email protected]/binary_reader.ts:4:10

    'buffer' is declared here.
      constructor(private buffer: Uint8Array) {}
        at https://deno.land/x/[email protected]/binary_reader.ts:9:15

TS2729 [ERROR]: Property 'buffer' is used before its initialization.
    this.buffer.byteLength,
         ~~~~~~
    at https://deno.land/x/[email protected]/binary_reader.ts:5:10

    'buffer' is declared here.
      constructor(private buffer: Uint8Array) {}
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~
        at https://deno.land/x/[email protected]/binary_reader.ts:9:15

Found 3 errors.

The problem is that the code to create dataBuffer, is being run before the constructor, and therefore before buffer is initialised.

Link to the code

I have created a pull request with a fix: #1

This is my first time making a pull request, so if there's anything in the process that I've done wrong, please let me know.

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.