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

benrr101 / node-taglib-sharp / 46462135

pending completion
46462135

push

appveyor

Benjamin Russell
Merge branch 'release/v5.1.0'

3096 of 3788 branches covered (81.73%)

Branch coverage included in aggregate %.

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

25320 of 26463 relevant lines covered (95.68%)

437.0 hits per line

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

95.56
/src/asf/objects/contentDescriptionObject.ts
1
import BaseObject from "./baseObject";
1✔
2
import ReadWriteUtils from "../readWriteUtils";
1✔
3
import {ByteVector} from "../../byteVector";
1✔
4
import {Guids, ObjectType} from "../constants";
1✔
5
import {CorruptFileError} from "../../errors";
1✔
6
import {File} from "../../file";
7

8
/**
9
 * This class extends {@link BaseObject} to provide a representation of an ASF content description
10
 * object. The content description object is optional and provides standard bibliographic
11
 * information such as title, author, copyright, description, rating information.
12
 */
13
export default class ContentDescriptionObject extends BaseObject {
1✔
14
    private _author: string = "";
131✔
15
    private _copyright: string = "";
131✔
16
    private _description: string = "";
131✔
17
    private _rating: string = "";
131✔
18
    private _title: string = "";
131✔
19

20
    // #region Constructors
21

22
    private constructor() {
23
        super();
131✔
24
    }
25

26
    /**
27
     * Constructs a blank content description object.
28
     */
29
    public static fromEmpty(): ContentDescriptionObject {
30
        const instance = new ContentDescriptionObject();
117✔
31
        instance.initializeFromGuid(Guids.ASF_CONTENT_DESCRIPTION_OBJECT);
117✔
32

33
        return instance;
117✔
34
    }
35

36
    /**
37
     * Constructs a new instance by reading from a file.
38
     * @param file File to read the content description object from
39
     * @param position Offset into the file where the object begins
40
     */
41
    public static fromFile(file: File, position: number): ContentDescriptionObject {
42
        const instance = new ContentDescriptionObject();
14✔
43
        instance.initializeFromFile(file, position);
14✔
44

45
        if (!instance.guid.equals(Guids.ASF_CONTENT_DESCRIPTION_OBJECT)) {
5!
46
            throw new CorruptFileError("Object GUID is not the expected content description object guid");
×
47
        }
48
        if (instance.originalSize < 34) {
5!
49
            throw new CorruptFileError("Object size too small for content description object");
×
50
        }
51

52
        const titleLength = ReadWriteUtils.readWord(file);
5✔
53
        const authorLength = ReadWriteUtils.readWord(file);
5✔
54
        const copyrightLength = ReadWriteUtils.readWord(file);
5✔
55
        const descriptionLength = ReadWriteUtils.readWord(file);
5✔
56
        const ratingLength = ReadWriteUtils.readWord(file);
5✔
57

58
        instance._title = ReadWriteUtils.readUnicode(file, titleLength);
5✔
59
        instance._author = ReadWriteUtils.readUnicode(file, authorLength);
5✔
60
        instance._copyright = ReadWriteUtils.readUnicode(file, copyrightLength);
5✔
61
        instance._description = ReadWriteUtils.readUnicode(file, descriptionLength);
5✔
62
        instance._rating = ReadWriteUtils.readUnicode(file, ratingLength);
5✔
63

64
        return instance;
5✔
65
    }
66

67
    // #endregion
68

69
    // #region Properties
70

71
    /**
72
     * Gets the author of the media described by the current instance.
73
     * @returns Author of the media or `undefined` if it is not set.
74
     */
75
    public get author(): string { return this._author || undefined; }
14✔
76
    /**
77
     * Sets the author of the media described by the current instance.
78
     */
79
    public set author(value: string) { this._author = value ?? ""; }
6✔
80

81
    /**
82
     * Gets the copyright information of the media described by the current instance.
83
     * @returns Copyright information of the media or `undefined` if it is not set.
84
     */
85
    public get copyright(): string { return this._copyright || undefined; }
14✔
86
    /**
87
     * Sets the copyright information of the media described by the current instance.
88
     */
89
    public set copyright(value: string) { this._copyright = value ?? ""; }
6✔
90

91
    /**
92
     * Gets the description of the media described by the current instance.
93
     * @returns Description of the media or `undefined` if it is not set.
94
     */
95
    public get description(): string { return this._description || undefined; }
14✔
96
    /**
97
     * Sets the description of the media described by the current instance.
98
     */
99
    public set description(value: string) { this._description = value ?? ""; }
6✔
100

101
    /**
102
     * Gets whether or not the current instance is empty.
103
     * @returns `true` if all the values are cleared. Otherwise `false` is returned.
104
     */
105
    public get isEmpty(): boolean {
106
        return !this._title
4✔
107
            && !this._author
108
            && !this._copyright
109
            && !this._description
110
            && !this._rating;
111
    }
112

113
    /** @inheritDoc */
114
    public get objectType(): ObjectType { return ObjectType.ContentDescriptionObject; }
10✔
115

116
    /**
117
     * Gets the rating of the media described by the current instance.
118
     * @returns Rating of the media or `undefined` if it is not set.
119
     */
120
    public get rating(): string { return this._rating || undefined; }
6✔
121
    /**
122
     * Sets the rating of the media described by the current instance.
123
     */
124
    public set rating(value: string) { this._rating = value ?? ""; }
4✔
125

126
    /**
127
     * Gets the title of the media described by the current instance.
128
     * @returns Title of the media or `undefined` if it is not set.
129
     */
130
    public get title(): string { return this._title || undefined; }
15✔
131
    /**
132
     * Sets the title of the media described by the current instance.
133
     */
134
    public set title(value: string) { this._title = value ?? ""; }
7✔
135

136
    // #endregion
137

138
    /**
139
     * Renders the current instance as a raw ASF object.
140
     */
141
    public render(): ByteVector {
142
        const titleBytes = ReadWriteUtils.renderUnicode(this._title);
10✔
143
        const authorBytes = ReadWriteUtils.renderUnicode(this._author);
10✔
144
        const copyrightBytes = ReadWriteUtils.renderUnicode(this._copyright);
10✔
145
        const descriptionBytes = ReadWriteUtils.renderUnicode(this._description);
10✔
146
        const ratingBytes = ReadWriteUtils.renderUnicode(this._rating);
10✔
147

148
        const data = ByteVector.concatenate(
10✔
149
            ReadWriteUtils.renderWord(titleBytes.length),
150
            ReadWriteUtils.renderWord(authorBytes.length),
151
            ReadWriteUtils.renderWord(copyrightBytes.length),
152
            ReadWriteUtils.renderWord(descriptionBytes.length),
153
            ReadWriteUtils.renderWord(ratingBytes.length),
154
            titleBytes,
155
            authorBytes,
156
            copyrightBytes,
157
            descriptionBytes,
158
            ratingBytes
159
        );
160

161
        return super.renderInternal(data);
10✔
162
    }
163
}
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