Passed
Pull Request — master (#160)
by
unknown
01:53
created

src/ID3Util.ts   A

Complexity

Total Complexity 6
Complexity/F 3

Size

Lines of Code 26
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 18
mnd 4
bc 4
fnc 2
dl 0
loc 26
rs 10
bpm 2
cpm 3
noi 0
c 0
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A ID3Util.ts ➔ getFrameOptions 0 7 2
A ID3Util.ts ➔ processUnsynchronisedBuffer 0 13 4
1
import { FrameOptions, FRAME_OPTIONS } from './definitions/FrameOptions'
2
import { isKeyOf } from './util'
3
4
export function getFrameOptions(frameIdentifier: string): FrameOptions {
5
    if (isKeyOf(frameIdentifier, FRAME_OPTIONS)) {
6
        return FRAME_OPTIONS[frameIdentifier]
7
    }
8
    return {
9
        multiple: false
10
    }
11
}
12
13
export function processUnsynchronisedBuffer(buffer: Buffer) {
14
    const newDataArr = []
15
    if (buffer.length > 0) {
16
        newDataArr.push(buffer[0])
17
    }
18
    for(let i = 1; i < buffer.length; i++) {
19
        if (buffer[i - 1] === 0xFF && buffer[i] === 0x00) {
20
            continue
21
        }
22
        newDataArr.push(buffer[i])
23
    }
24
    return Buffer.from(newDataArr)
25
}
26