From 47d8f28e67287766b2ff7fac8e560b763d4f5e97 Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Sat, 18 Sep 2021 23:16:50 +0200 Subject: [PATCH] Added experimental autoFreezable method in bundle (probably I'll regret it) --- src/Bundle.ts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Bundle.ts b/src/Bundle.ts index 966fcf8..6580e0b 100644 --- a/src/Bundle.ts +++ b/src/Bundle.ts @@ -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 * can be added any further. */ - private freeze() { + protected freeze() { if (this[bundleStateSymbol] === BundleState.CLOSED) { return; }