Skip to content

Commit

Permalink
Update var-header.js
Browse files Browse the repository at this point in the history
  • Loading branch information
twitchyvr committed Nov 20, 2023
1 parent ad87553 commit 13b12ad
Showing 1 changed file with 31 additions and 14 deletions.
45 changes: 31 additions & 14 deletions src/headers/var-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,41 @@ const SIZE_IN_BYTES = 144
*/
class VarHeader {
/**
* Construct an instance of VarHeader
*
* params = {
* type,
* offset,
* count,
* countAsTime,
* name,
* description,
* unit
* }
*/
* Create a VarHeader instance.
*
* @param {Object} params - Parameters for the header
*/
constructor (params) {
Object.assign(this, params)
if (!params.name) {
throw new Error('VarHeader requires a name')
}

const headerParams = {
type: 0,
offset: '',
count: 0,
countAsTime: 0,
name: '',
description: '',
unit: ''
}

Object.assign(this, headerParams)
}

get name () {
return this._name
}

get type () {
return this._type
}

/**
* Instantiate VarHeader from the contents of the supplied buffer
* Create VarHeader from a buffer.
*
* @param {Buffer} buffer - Buffer containing the header data
* @returns {VarHeader}
*/
static fromBuffer (buffer) {
if (buffer.length !== SIZE_IN_BYTES) {
Expand Down

0 comments on commit 13b12ad

Please sign in to comment.