mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 18:25:24 +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 filesSymbol = Symbol("bundleFiles");
|
||||||
export const freezeSymbol = Symbol("bundleFreeze");
|
export const freezeSymbol = Symbol("bundleFreeze");
|
||||||
|
export const mimeTypeSymbol = Symbol("bundleMimeType");
|
||||||
|
|
||||||
namespace Mime {
|
namespace Mime {
|
||||||
export type type = string;
|
export type type = string;
|
||||||
@@ -18,11 +19,14 @@ namespace Mime {
|
|||||||
|
|
||||||
export default class Bundle {
|
export default class Bundle {
|
||||||
private [filesSymbol]: { [key: string]: Buffer } = {};
|
private [filesSymbol]: { [key: string]: Buffer } = {};
|
||||||
|
private [mimeTypeSymbol]: string;
|
||||||
|
|
||||||
constructor(public mimeType: `${Mime.type}/${Mime.subtype}`) {
|
constructor(mimeType: `${Mime.type}/${Mime.subtype}`) {
|
||||||
if (!mimeType) {
|
if (!mimeType) {
|
||||||
throw new Error(Messages.BUNDLE.MIME_TYPE_MISSING);
|
throw new Error(Messages.BUNDLE.MIME_TYPE_MISSING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this[mimeTypeSymbol] = mimeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,6 +57,14 @@ export default class Bundle {
|
|||||||
return [bundle, () => bundle[freezeSymbol]()];
|
return [bundle, () => bundle[freezeSymbol]()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves bundle's mimeType
|
||||||
|
*/
|
||||||
|
|
||||||
|
public get mimeType() {
|
||||||
|
return this[mimeTypeSymbol];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Freezes the bundle so no more files
|
* Freezes the bundle so no more files
|
||||||
* can be added any further.
|
* can be added any further.
|
||||||
|
|||||||
Reference in New Issue
Block a user