mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 18:25:24 +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";
|
import { ZipFile } from "yazl";
|
||||||
|
|
||||||
export const filesSymbol = Symbol("bundleFiles");
|
export const filesSymbol = Symbol("bundleFiles");
|
||||||
const bundleStateSymbol = Symbol("state");
|
|
||||||
const archiveSymbol = Symbol("zip");
|
const archiveSymbol = Symbol("zip");
|
||||||
|
|
||||||
enum BundleState {
|
|
||||||
CLOSED = 0,
|
|
||||||
OPEN = 1,
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Mime {
|
namespace Mime {
|
||||||
export type type = string;
|
export type type = string;
|
||||||
export type subtype = string;
|
export type subtype = string;
|
||||||
@@ -22,7 +16,6 @@ namespace Mime {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export default class Bundle {
|
export default class Bundle {
|
||||||
private [bundleStateSymbol]: BundleState = BundleState.OPEN;
|
|
||||||
private [filesSymbol]: { [key: string]: Buffer } = {};
|
private [filesSymbol]: { [key: string]: Buffer } = {};
|
||||||
private [archiveSymbol] = new ZipFile();
|
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.
|
* can be added any further.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -65,7 +58,7 @@ export default class Bundle {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this[bundleStateSymbol] = BundleState.CLOSED;
|
Object.freeze(this[filesSymbol]);
|
||||||
this[archiveSymbol].end();
|
this[archiveSymbol].end();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +68,7 @@ export default class Bundle {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public get isFrozen() {
|
public get isFrozen() {
|
||||||
return this[bundleStateSymbol] === BundleState.CLOSED;
|
return Object.isFrozen(this[filesSymbol]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user