Skip to content

Commit e195e5e

Browse files
Replace collections map by native map
1 parent cdf8270 commit e195e5e

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

index.js

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"author": "Ber-Lin Lai <berlin.lai@gmail.com>",
1515
"license": "BSD",
1616
"dependencies": {
17-
"collections": "^3.0.0",
1817
"node-zip": "1.x"
1918
},
2019
"devDependencies": {

sheet.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,16 @@ var addStringCell = function(sheet, cellRef, value, styleIndex){
145145
if (typeof value ==='string'){
146146
value = value.replace(/&/g, "&amp;").replace(/'/g, "&apos;").replace(/>/g, "&gt;").replace(/</g, "&lt;");
147147
}
148-
var i = sheet.shareStrings.get(value, -1);
148+
// TODO there is no default value in js map
149+
var i
150+
if (!sheet.shareStrings.has(value)) {
151+
i = -1
152+
} else {
153+
i = sheet.shareStrings.get(value)
154+
}
149155
if ( i< 0){
150-
i = sheet.shareStrings.length;
151-
sheet.shareStrings.add(value, i);
156+
i = sheet.shareStrings.size;
157+
sheet.shareStrings.set(value, i);
152158
sheet.convertedShareStrings += "<x:si><x:t>"+value+"</x:t></x:si>";
153159
}
154160
return '<x:c r="'+cellRef+'" s="'+ styleIndex + '" t="s"><x:v>'+i+'</x:v></x:c>';

0 commit comments

Comments
 (0)