madden-franchise 2.5.2 → 2.5.5

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.
package/FranchiseFile.js CHANGED
@@ -113,7 +113,7 @@ class FranchiseFile extends EventEmitter {
113
113
 
114
114
  for (let i = 0; i < tableIndicies.length; i++) {
115
115
  const currentTable = tableIndicies[i];
116
- const nextTable = tableIndicies.length >= i+1 ? tableIndicies[i+1] : null;
116
+ const nextTable = tableIndicies.length > i+1 ? tableIndicies[i+1] : this.unpackedFileContents.length - 8; // Ignore trailing 8 bytes on last table
117
117
 
118
118
  const tableData = this.unpackedFileContents.slice(currentTable, nextTable);
119
119
 
@@ -190,14 +190,26 @@ class FranchiseFile extends EventEmitter {
190
190
 
191
191
  _packFile(this.unpackedFileContents, options).then((data) => {
192
192
  const dataToSave = this.strategy.file.postPackFile(this.packedFileContents, data);
193
- _save(destination, dataToSave, (err) => {
193
+
194
+ if (options && options.sync) {
195
+ _saveSync(destination, dataToSave);
196
+ postSaveActions();
197
+ }
198
+ else {
199
+ _save(destination, dataToSave, (err) => {
200
+ postSaveActions(err);
201
+ });
202
+ }
203
+
204
+ function postSaveActions(err) {
194
205
  if (err) {
195
206
  reject(err);
196
207
  that.emit('save-error');
197
208
  }
209
+
198
210
  resolve('saved');
199
211
  that.emit('saved');
200
- });
212
+ }
201
213
  });
202
214
  });
203
215
  };
@@ -339,11 +351,11 @@ function unpackFile (data, type) {
339
351
  function _packFile (data, options) {
340
352
  return new Promise((resolve, reject) => {
341
353
  if (options && options.sync) {
342
- const data = zlib.deflateSync(data, {
354
+ const newData = zlib.deflateSync(data, {
343
355
  windowBits: 15
344
356
  });
345
357
 
346
- resolve(data);
358
+ resolve(newData);
347
359
  }
348
360
  else {
349
361
  zlib.deflate(data, {
@@ -361,6 +373,10 @@ function _save (destination, packedContents, callback) {
361
373
  fs.writeFile(destination, packedContents, callback);
362
374
  };
363
375
 
376
+ function _saveSync (destination, packedContents) {
377
+ fs.writeFileSync(destination, packedContents);
378
+ };
379
+
364
380
  function getFileType(data) {
365
381
  const isDataCompressed = isCompressed(data);
366
382
  const format = getFormat(data, isDataCompressed);
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "madden-franchise",
3
- "version": "2.5.2",
3
+ "version": "2.5.5",
4
4
  "description": "Tools to read a madden franchise file and get data from it",
5
5
  "main": "FranchiseFile.js",
6
6
  "scripts": {