• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

benrr101 / node-taglib-sharp / 51161498

13 Dec 2024 04:24AM UTC coverage: 92.554%. Remained the same
51161498

push

appveyor

benrr101
Merge branch 'release/v6.0.1' into develop

3251 of 4131 branches covered (78.7%)

Branch coverage included in aggregate %.

26753 of 28287 relevant lines covered (94.58%)

471.62 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

10.0
/src/mpeg4/descriptorTagReader.ts
1
import { ByteVector } from "../byteVector";
2
import {Guards, NumberUtils} from "../utils";
1✔
3

4
/**
5
 * Provides methods to read descriptor tags
6
 * @internal
7
 */
8
export class DescriptorTagReader {
1✔
9
    private _data: ByteVector;
10
    private _length: number;
11
    private _offset: number;
12

13
    /**
14
     * Constructs and initializes a new descriptor tag reader with the data from which to read the
15
     * descriptor tag.
16
     * @param data Data from which the descriptor tag should be read
17
     */
18
    public constructor(data: ByteVector) {
19
        Guards.truthy(data, "data");
×
20

21
        this._data = data;
×
22
        this._length = 0;
×
23
        this._offset = 0;
×
24
    }
25

26
    /**
27
     * Gets the length of the descriptor tag.
28
     */
29
    public get length(): number { return this._length; }
×
30

31
    /**
32
     * Gets the offset of the descriptor tag.
33
     */
34
    public get offset(): number { return this._offset; }
×
35

36
    /**
37
     * Reads a section length and updates the offset to the end of the length block.
38
     * @returns number Length that was read.
39
     */
40
    public readLength(): number {
41
        let b = 0;
×
42
        const end = this._offset + 4;
×
43

44
        do {
×
45
            b = this._data.get(this._offset++);
×
46
            this._length = NumberUtils.uintOr(NumberUtils.uintLShift(this._length, 7), NumberUtils.uintAnd(b, 0x7f));
×
47
        } while (NumberUtils.uintAnd(b, 0x80) !== 0 && this._offset <= end);
×
48
        // The length could be between 1 and 4 bytes for each descriptor
49

50
        return this._length;
×
51
    }
52

53
    /**
54
     * Increases the current offset by a given value
55
     * @param value A number by which the offset should be increased
56
     * @returns number Offset before increase
57
     */
58
    public increaseOffset(value: number): number {
59
        Guards.safeUint(value, "value");
×
60

61
        const previousOffset = this._offset;
×
62
        this._offset += value;
×
63

64
        return previousOffset;
×
65
    }
66
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc