Skip to content

Commit

Permalink
style(frame): encodeBytes/decodeBytes function names are flipped
Browse files Browse the repository at this point in the history
  • Loading branch information
Neonox31 authored Jul 29, 2018
1 parent 8383005 commit 8bc3365
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/frame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ const removeDuplicate = (_: any, idx: number, frame: number[][]): boolean => {
return first !== 0x2
}

const encodeBytes = (bytesPair: [number, number]): number => {
const decodeBytes = (bytesPair: [number, number]): number => {
return bytesPair[0] === 0x2 ? bytesPair[1] ^ 0x10 : bytesPair[0]
}

// const decodeByte = (byte: number): number[] => {
// const encodeByte = (byte: number): number[] => {
// return byte >= 0x10 ? [byte] : [0x2, byte ^ 0x10]
// }

Expand All @@ -55,15 +55,15 @@ const decodeFrame = (frame: Buffer): Buffer => {
const arrFrame = Array.from(frame)
.map(combineBytes)
.filter(removeDuplicate)
.map(encodeBytes)
.map(decodeBytes)

return Buffer.from(arrFrame)
}

// const encodeFrame = (frame: Buffer): Buffer => {
// const arrFrame = Array
// .from(frame)
// .flatMap(decodeByte)
// .flatMap(encodeByte)
//
// return Buffer.from(arrFrame);
// }
Expand Down

0 comments on commit 8bc3365

Please sign in to comment.