• 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

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

8
/**
9
 * This class provides a representation of an ASF padding object which can be read from and
10
 * written to disk.
11
 */
12
export default class PaddingObject extends BaseObject {
1✔
13
    /**
14
     * Length of the padding object header in bytes.
15
     */
16
    public static readonly HEADER_LENGTH = 24;
1✔
17

18
    private _size: number;
19

20
    // #region Constructors
21

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

26
    /**
27
     * Constructs and initializes a new instance by reading it from a file.
28
     * @param file File to read the padding object from
29
     * @param position Index into the file where the padding object starts from
30
     */
31
    public static fromFile(file: File, position: number): PaddingObject {
32
        const instance = new PaddingObject();
4✔
33
        instance.initializeFromFile(file, position);
4✔
34

35
        if (!instance.guid.equals(Guids.ASF_PADDING_OBJECT)) {
4!
36
            throw new CorruptFileError("Object GUID does not match expected padding object GUID");
×
37
        }
38

39
        instance._size = instance.originalSize - PaddingObject.HEADER_LENGTH;
4✔
40
        return instance;
4✔
41
    }
42

43
    /**
44
     * Constructs and initializes a new instance with a fixed size.
45
     * @param size Number of padding bytes to store in the object not including the size of the
46
     *     header
47
     */
48
    public static fromSize(size: number): PaddingObject {
49
        Guards.safeUint(size, "size");
8✔
50

51
        const instance = new PaddingObject();
8✔
52
        instance.initializeFromGuid(Guids.ASF_PADDING_OBJECT);
8✔
53
        instance._size = size;
8✔
54

55
        return instance;
8✔
56
    }
57

58
    // #endregion
59

60
    // #region Properties
61

62
    /** @inheritDoc */
63
    public get objectType(): ObjectType { return ObjectType.PaddingObject; }
11✔
64

65
    /**
66
     * Gets the number of bytes the current instance will take up on disk. Note: this does *not*
67
     * include the header for the object.
68
     */
69
    public get size(): number { return this._size; }
×
70
    /**
71
     * Sets the number of padding bytes the current instance will contain. Note: this does *not*
72
     * include the header for the object.
73
     * @param value Size of the current instance in bytes, must be a safe, positive integer.
74
     */
75
    public set size(value: number) {
76
        Guards.safeUint(value, "value");
×
77
        this._size = value;
×
78
    }
79

80
    // #endregion
81

82
    /** @inheritDoc */
83
    public render(): ByteVector {
84
        return super.renderInternal(ByteVector.fromSize(this._size));
7✔
85
    }
86
}
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