madden-franchise 2.5.1 → 2.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/FranchiseFile.js +21 -22
  2. package/package.json +1 -1
package/FranchiseFile.js CHANGED
@@ -175,30 +175,20 @@ class FranchiseFile extends EventEmitter {
175
175
  });
176
176
  };
177
177
 
178
- save(outputFilePath) {
179
- return this.packFile(outputFilePath);
178
+ save(outputFilePath, options) {
179
+ return this.packFile(outputFilePath, options);
180
180
  };
181
181
 
182
- packFile(outputFilePath) {
182
+ packFile(outputFilePath, options) {
183
183
  const that = this;
184
184
  this.emit('saving');
185
185
 
186
186
  return new Promise((resolve, reject) => {
187
187
  this.unpackedFileContents = this.strategy.file.generateUnpackedContents(this.tables, this.unpackedFileContents);
188
- // const changedTables = this.tables.filter((table) => { return table.isChanged; });
189
-
190
- // for (let i = 0; i < changedTables.length; i++) {
191
- // let table = changedTables[i];
192
- // const header = that.unpackedFileContents.slice(0, table.offset);
193
- // const trailer = that.unpackedFileContents.slice(table.offset + table.data.length);
194
- // that.unpackedFileContents = Buffer.concat([header, table.hexData, trailer]);
195
-
196
- // table.isChanged = false;
197
- // }
198
188
 
199
189
  let destination = outputFilePath ? outputFilePath : this.filePath;
200
190
 
201
- _packFile(this.unpackedFileContents).then((data) => {
191
+ _packFile(this.unpackedFileContents, options).then((data) => {
202
192
  const dataToSave = this.strategy.file.postPackFile(this.packedFileContents, data);
203
193
  _save(destination, dataToSave, (err) => {
204
194
  if (err) {
@@ -346,15 +336,24 @@ function unpackFile (data, type) {
346
336
  return zlib.inflateSync(data.slice(offset));
347
337
  };
348
338
 
349
- function _packFile (data) {
339
+ function _packFile (data, options) {
350
340
  return new Promise((resolve, reject) => {
351
- zlib.deflate(data, {
352
- windowBits: 15
353
- }, function (err, newData) {
354
- if (err) reject(err);
355
-
356
- resolve(newData);
357
- });
341
+ if (options && options.sync) {
342
+ const data = zlib.deflateSync(data, {
343
+ windowBits: 15
344
+ });
345
+
346
+ resolve(data);
347
+ }
348
+ else {
349
+ zlib.deflate(data, {
350
+ windowBits: 15
351
+ }, function (err, newData) {
352
+ if (err) reject(err);
353
+
354
+ resolve(newData);
355
+ });
356
+ }
358
357
  });
359
358
  };
360
359
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "madden-franchise",
3
- "version": "2.5.1",
3
+ "version": "2.5.2",
4
4
  "description": "Tools to read a madden franchise file and get data from it",
5
5
  "main": "FranchiseFile.js",
6
6
  "scripts": {