Added experimental autoFreezable method in bundle (probably I'll regret it)

This commit is contained in:
Alexander Cerutti
2021-09-18 23:16:50 +02:00
parent a38c235cf8
commit 47d8f28e67

View File

@@ -32,12 +32,35 @@ export default class Bundle {
} }
} }
/**
* @EXPERIMENTAL
*
* @param mimeType
*/
static autoFreezable(mimeType: `${Mime.type}/${Mime.subtype}`): Bundle {
const bundle = new Bundle(mimeType);
/**
* @TODO
* Might not be the best idea I might have had.
* I have to test this further more to check if
* actually we can leverage of this event loop feature
* to freeze it automatically once we processed every
* promise for bundling;
*/
setTimeout(bundle.freeze, 0);
return bundle;
}
/** /**
* Freezes / Closes the bundle so no more files * Freezes / Closes the bundle so no more files
* can be added any further. * can be added any further.
*/ */
private freeze() { protected freeze() {
if (this[bundleStateSymbol] === BundleState.CLOSED) { if (this[bundleStateSymbol] === BundleState.CLOSED) {
return; return;
} }