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

benrr101 / node-taglib-sharp / 48387615

28 Oct 2023 05:25AM UTC coverage: 92.442% (+0.02%) from 92.427%
48387615

push

appveyor

benrr101
Ok two more tweaks

3250 of 4147 branches covered (0.0%)

Branch coverage included in aggregate %.

2 of 2 new or added lines in 2 files covered. (100.0%)

26753 of 28309 relevant lines covered (94.5%)

422.49 hits per line

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

78.79
/src/mpeg4/boxes/appleDataBox.ts
1
import FullBox from "./fullBox";
1✔
2
import Mpeg4BoxHeader from "../mpeg4BoxHeader";
3
import Mpeg4BoxType from "../mpeg4BoxType";
1✔
4
import {ByteVector, StringType} from "../../byteVector";
1✔
5
import {File} from "../../file";
6
import {Guards, NumberUtils} from "../../utils";
1✔
7

8
/**
9
 * Specifies the type of data contained in a box.
10
 */
11
export enum AppleDataBoxFlagType {
1✔
12
    /**
13
     * The box contains binary data.
14
     */
15
    ContainsData = 0x00,
1✔
16

17
    /**
18
     * The box contains UTF-8 text.
19
     */
20
    ContainsText = 0x01,
1✔
21

22
    /**
23
     * The box contains a raw JPEG image.
24
     */
25
    ContainsJpegData = 0x0d,
1✔
26

27
    /**
28
     * The box contains a raw PNG image.
29
     */
30
    ContainsPngData = 0x0e,
1✔
31

32
    /**
33
     * The box contains data for a tempo box.
34
     */
35
    ForTempo = 0x15,
1✔
36

37
    /**
38
     * The box contains a raw BMP image.
39
     */
40
    ContainsBmpData = 0x1b,
1✔
41
}
42

43
/**
44
 * This class extends @see FullBox to provide an implementation of an Apple DataBox.
45
 */
46
export class AppleDataBox extends FullBox {
1✔
47
    /**
48
     * Private constructor to force construction via static functions.
49
     */
50
    private constructor() {
51
        super();
264✔
52
    }
53

54
    /**
55
     * Constructs and initializes a new instance of @see AppleDataBox with a provided header and handler
56
     * by reading the contents from a specified file.
57
     * @param header A @see Mpeg4BoxHeader  object containing the header to use for the new instance.
58
     * @param file A @see File object to read the contents of the box from.
59
     * @param handlerType Type of the handler box object containing the handler that applies to the
60
     *     new instance, or undefined if no handler applies.
61
     * @returns A new instance of @see AppleDataBox
62
     */
63
    public static fromFile(header: Mpeg4BoxHeader, file: File, handlerType: ByteVector): AppleDataBox {
64
        const instance = new AppleDataBox();
×
65
        instance.initializeFromHeaderFileAndHandler(header, file, handlerType);
×
66
        instance.increaseDataPosition(4);
×
67
        instance.data = instance.loadData(file);
×
68

69
        return instance;
×
70
    }
71

72
    /**
73
     * Constructs and initializes a new instance of @see AppleDataBox with specified data and flags.
74
     * @param data A @see ByteVector object containing the data to store in the new instance.
75
     * @param flags A value containing flags to use for the new instance.
76
     * @returns
77
     */
78
    public static fromDataAndFlags(data: ByteVector, flags: number): AppleDataBox {
79
        Guards.truthy(data, "data");
264✔
80

81
        const instance = new AppleDataBox();
264✔
82
        instance.initializeFromTypeVersionAndFlags(Mpeg4BoxType.DATA, 0, flags);
264✔
83
        instance.increaseDataPosition(4);
264✔
84
        instance.data = data;
264✔
85

86
        return instance;
264✔
87
    }
88

89
    /**
90
     * Gets the text contained in the current instance.
91
     */
92
    public get text(): string {
93
        return NumberUtils.hasFlag(this.flags, AppleDataBoxFlagType.ContainsText)
375✔
94
            ? this.data.toString(StringType.UTF8)
375!
95
            : undefined;
96
    }
97
    /**
98
     * Sets the text contained in the current instance.
99
     */
100
    public set text(v: string) {
101
        Guards.notNullOrUndefined(v, "v");
34✔
102
        this.flags = AppleDataBoxFlagType.ContainsText;
34✔
103
        this.data = ByteVector.fromString(v, StringType.UTF8);
34✔
104
    }
105

106
    public renderBoxHeaders(): ByteVector[] {
107
        return [
×
108
            ...super.renderBoxHeaders(),
109
            ByteVector.fromSize(4)
110
        ];
111
    }
112
}
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

© 2026 Coveralls, Inc