Skip to content
This repository has been archived by the owner. It is now read-only.
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

OER Utils

Greenkeeper badge

npm circle codecov

Collection of tools for OER parsing and serialization

Usage

npm install oer-utils

Numbers in oer-utils

This module uses the long library to avoid issues with JavaScript numbers.

Writer methods for writing integers, like writeUInt8 or writeVarInt, accept numbers, strings, or Longs.

The Reader exposes methods for reading integers that return strings, such as readInt16 and readVarUInt, as well as methods that return Longs, such as readInt16Long and readVarUIntLong.

Note that if the long API changes, there will be breaking changes to the read...Long methods. These methods may be used to avoid unnecessary string conversions, but they may be less stable in the long term than the methods that export strings.

Examples

Parse a binary buffer

const Reader = require('oer-utils/reader')

const reader = Reader.from(new Buffer('1234', 'hex'))

const v1 = reader.readUInt8()
const v2 = reader.readUInt8Long()

Write a binary file

const Writer = require('oer-utils/writer')
const Long = require('long')

const writer = new Writer()

writer.writeUInt8(1)
writer.writeUInt8(Long.fromNumber(2, true))

const buffer = writer.getBuffer()
You can’t perform that action at this time.