Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decode buffers as hex #136

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions test/dataTypes/prepareTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,19 @@ const testData = [
}
]

function arrayToBuffer (arr) {
return Buffer.from(arr.map(e => parseInt(e)))
}

function transformValues (type, values) {
return values.map(val => {
let value = val.value
if (type.indexOf('buffer') === 0) {
value = arrayToBuffer(value)
value = Buffer.from(value, 'hex')
} else if (value) {
// we cannot use undefined type in JSON so need to convert it here to pass strictEquals test
for (const key in value) {
if (value[key] === 'undefined') value[key] = undefined
}
}
return {
buffer: arrayToBuffer(val.buffer),
buffer: Buffer.from(val.buffer, 'hex'),
value,
description: val.description
}
Expand Down