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

benrr101 / node-taglib-sharp / 48257345

12 Oct 2023 04:06AM UTC coverage: 92.315% (+0.4%) from 91.944%
48257345

push

appveyor

benrr101
Performer roles (bug fixed), genres

3226 of 4153 branches covered (0.0%)

Branch coverage included in aggregate %.

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

27069 of 28664 relevant lines covered (94.44%)

417.21 hits per line

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

73.53
/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 {Mpeg4BoxClassType} from "../mpeg4BoxClassType";
1✔
7
import {Guards, NumberUtils} from "../../utils";
1✔
8

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

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

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

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

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

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

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

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

67
        const instance = new AppleDataBox();
×
68
        instance.initializeFromHeaderFileAndHandler(header, file, handlerType);
×
69
        instance.increaseDataPosition(4);
×
70
        instance.data = instance.loadData(file);
×
71

72
        return instance;
×
73
    }
74

75
    /**
76
     * Constructs and initializes a new instance of @see AppleDataBox with specified data and flags.
77
     * @param data A @see ByteVector object containing the data to store in the new instance.
78
     * @param flags A value containing flags to use for the new instance.
79
     * @returns
80
     */
81
    public static fromDataAndFlags(data: ByteVector, flags: number): AppleDataBox {
82
        const instance = new AppleDataBox();
253✔
83
        instance.initializeFromTypeVersionAndFlags(Mpeg4BoxType.DATA, 0, flags);
253✔
84
        instance.increaseDataPosition(4);
253✔
85
        instance.data = data;
253✔
86

87
        return instance;
253✔
88
    }
89

90
    /** @inheritDoc */
91
    public get boxClassType(): Mpeg4BoxClassType { return Mpeg4BoxClassType.AppleDataBox; }
×
92

93
    /**
94
     * Gets the text contained in the current instance.
95
     */
96
    public get text(): string {
97
        return NumberUtils.hasFlag(this.flags, AppleDataBoxFlagType.ContainsText)
366✔
98
            ? this.data.toString(StringType.UTF8)
366!
99
            : undefined;
100
    }
101
    /**
102
     * Sets the text contained in the current instance.
103
     */
104
    public set text(v: string) {
105
        this.flags = AppleDataBoxFlagType.ContainsText;
37✔
106
        this.data = ByteVector.fromString(v, StringType.UTF8);
37✔
107
    }
108

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