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

benrr101 / node-taglib-sharp / 48393127

29 Oct 2023 04:39AM UTC coverage: 92.535% (-1.4%) from 93.934%
48393127

push

appveyor

benrr101
Merge branch 'release/v5.2.0'

3244 of 4129 branches covered (0.0%)

Branch coverage included in aggregate %.

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

26728 of 28261 relevant lines covered (94.58%)

423.2 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 {@link 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 {@link AppleDataBox} with a provided header and handler
56
     * by reading the contents from a specified file.
57
     * @param header A {@link Mpeg4BoxHeader} object containing the header to use for the new instance.
58
     * @param file A {@link 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
     */
62
    public static fromFile(header: Mpeg4BoxHeader, file: File, handlerType: ByteVector): AppleDataBox {
63
        const instance = new AppleDataBox();
×
64
        instance.initializeFromHeaderFileAndHandler(header, file, handlerType);
×
65
        instance.increaseDataPosition(4);
×
66
        instance.data = instance.loadData(file);
×
67

68
        return instance;
×
69
    }
70

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

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

84
        return instance;
264✔
85
    }
86

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

104
    /**
105
     * Renders the headers for the box.
106
     * @returns ByteVector Rendered headers of the current instance
107
     */
108
    public renderBoxHeaders(): ByteVector[] {
109
        return [
×
110
            ...super.renderBoxHeaders(),
111
            ByteVector.fromSize(4)
112
        ];
113
    }
114
}
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