mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 14:25:17 +00:00
Replaced BundleState with freeze state of Bundle.prototype[filesSymbol]
This commit is contained in:
@@ -2,14 +2,8 @@ import { Stream } from "stream";
|
||||
import { ZipFile } from "yazl";
|
||||
|
||||
export const filesSymbol = Symbol("bundleFiles");
|
||||
const bundleStateSymbol = Symbol("state");
|
||||
const archiveSymbol = Symbol("zip");
|
||||
|
||||
enum BundleState {
|
||||
CLOSED = 0,
|
||||
OPEN = 1,
|
||||
}
|
||||
|
||||
namespace Mime {
|
||||
export type type = string;
|
||||
export type subtype = string;
|
||||
@@ -22,7 +16,6 @@ namespace Mime {
|
||||
*/
|
||||
|
||||
export default class Bundle {
|
||||
private [bundleStateSymbol]: BundleState = BundleState.OPEN;
|
||||
private [filesSymbol]: { [key: string]: Buffer } = {};
|
||||
private [archiveSymbol] = new ZipFile();
|
||||
|
||||
@@ -56,7 +49,7 @@ export default class Bundle {
|
||||
}
|
||||
|
||||
/**
|
||||
* Freezes / Closes the bundle so no more files
|
||||
* Freezes the bundle so no more files
|
||||
* can be added any further.
|
||||
*/
|
||||
|
||||
@@ -65,7 +58,7 @@ export default class Bundle {
|
||||
return;
|
||||
}
|
||||
|
||||
this[bundleStateSymbol] = BundleState.CLOSED;
|
||||
Object.freeze(this[filesSymbol]);
|
||||
this[archiveSymbol].end();
|
||||
}
|
||||
|
||||
@@ -75,7 +68,7 @@ export default class Bundle {
|
||||
*/
|
||||
|
||||
public get isFrozen() {
|
||||
return this[bundleStateSymbol] === BundleState.CLOSED;
|
||||
return Object.isFrozen(this[filesSymbol]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user