mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 16:25:21 +00:00
Moved bundle.mimeType behind a symbol + getter to prevent changing
This commit is contained in:
@@ -4,6 +4,7 @@ import * as zip from "do-not-zip";
|
||||
|
||||
export const filesSymbol = Symbol("bundleFiles");
|
||||
export const freezeSymbol = Symbol("bundleFreeze");
|
||||
export const mimeTypeSymbol = Symbol("bundleMimeType");
|
||||
|
||||
namespace Mime {
|
||||
export type type = string;
|
||||
@@ -18,11 +19,14 @@ namespace Mime {
|
||||
|
||||
export default class Bundle {
|
||||
private [filesSymbol]: { [key: string]: Buffer } = {};
|
||||
private [mimeTypeSymbol]: string;
|
||||
|
||||
constructor(public mimeType: `${Mime.type}/${Mime.subtype}`) {
|
||||
constructor(mimeType: `${Mime.type}/${Mime.subtype}`) {
|
||||
if (!mimeType) {
|
||||
throw new Error(Messages.BUNDLE.MIME_TYPE_MISSING);
|
||||
}
|
||||
|
||||
this[mimeTypeSymbol] = mimeType;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,6 +57,14 @@ export default class Bundle {
|
||||
return [bundle, () => bundle[freezeSymbol]()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves bundle's mimeType
|
||||
*/
|
||||
|
||||
public get mimeType() {
|
||||
return this[mimeTypeSymbol];
|
||||
}
|
||||
|
||||
/**
|
||||
* Freezes the bundle so no more files
|
||||
* can be added any further.
|
||||
|
||||
Reference in New Issue
Block a user