Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Commit

Permalink
issue 269 fix. change Object lookup to Map
Browse files Browse the repository at this point in the history
  • Loading branch information
natergj committed Mar 24, 2019
1 parent 1154b9e commit 52b956f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions source/lib/workbook/workbook.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ class Workbook {

this.sheets = [];
this.sharedStrings = [];
this.sharedStringLookup = {};
this.sharedStringLookup = new Map();
this.styles = [];
this.stylesLookup = {};
this.stylesLookup = new Map();
this.dxfCollection = new DXFCollection(this);
this.mediaCollection = new MediaCollection();
this.definedNameCollection = new DefinedNameCollection();
Expand Down Expand Up @@ -242,11 +242,11 @@ class Workbook {
const lookupKey = JSON.stringify(thisStyle.toObject());

// Use existing style if one exists
if (this.stylesLookup[lookupKey]) {
return this.stylesLookup[lookupKey];
if (this.stylesLookup.get(lookupKey)) {
return this.stylesLookup.get(lookupKey);
}

this.stylesLookup[lookupKey] = thisStyle;
this.stylesLookup.set(lookupKey, thisStyle);
const index = this.styles.push(thisStyle) - 1;
this.styles[index].ids.cellXfs = index;
return this.styles[index];
Expand All @@ -258,10 +258,10 @@ class Workbook {
* @returns {Number} index of the string in the shared strings array
*/
getStringIndex(val) {
const target = this.sharedStringLookup[val];
const target = this.sharedStringLookup.get(val);
if (_isUndefined(target)) {
const index = this.sharedStrings.push(val) - 1;
this.sharedStringLookup[val] = index;
this.sharedStringLookup.set(val, index);
return index;
} else {
return target;
Expand Down

0 comments on commit 52b956f

Please sign in to comment.