mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 19:25:23 +00:00
Added method with tests getAsRaw
This commit is contained in:
@@ -127,4 +127,19 @@ export default class Bundle {
|
||||
this[freezeSymbol]();
|
||||
return this[archiveSymbol].outputStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the bundle and returns it as an object.
|
||||
* This allows developers to choose a different way
|
||||
* of serving, analyzing or zipping the file, outside the
|
||||
* default compression system.
|
||||
*
|
||||
* @returns a frozen object containing files paths as key
|
||||
* and Buffers as content.
|
||||
*/
|
||||
|
||||
public getAsRaw(): { [filePath: string]: Buffer } {
|
||||
this[freezeSymbol]();
|
||||
return Object.freeze({ ...this[filesSymbol] });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -630,6 +630,28 @@ export default class PKPass extends Bundle {
|
||||
return super.getAsStream();
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports the pass as a list of file paths and buffers.
|
||||
* When this method is invoked, the bundle will get
|
||||
* frozen and, thus, no files will be allowed to be
|
||||
* added any further.
|
||||
*
|
||||
* This allows developers to choose a different way
|
||||
* of serving, analyzing or zipping the file, outside the
|
||||
* default compression system.
|
||||
*
|
||||
* @returns a frozen object containing files paths as key
|
||||
* and Buffers as content.
|
||||
*/
|
||||
|
||||
public getAsRaw(): { [filePath: string]: Buffer } {
|
||||
if (!this.isFrozen) {
|
||||
this[closePassSymbol]();
|
||||
}
|
||||
|
||||
return super.getAsRaw();
|
||||
}
|
||||
|
||||
// ************************** //
|
||||
// *** DATA SETUP METHODS *** //
|
||||
// ************************** //
|
||||
|
||||
Reference in New Issue
Block a user