aboutsummaryrefslogtreecommitdiff
path: root/lib/docx/style-map.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2015-08-12 21:57:45 +0100
committerMichael Williamson <mike@zwobble.org>2015-08-12 21:57:45 +0100
commit4b4ec85bc4f49e72244f7219539124b45b876d8e (patch)
tree0aa4c2005526fa5130bccbfd26f3a9cab6f8d4cb /lib/docx/style-map.js
parent5f5217a4e16f7be697b24a46cf58e47753967d95 (diff)
Open zip file before passing to readers
Diffstat (limited to 'lib/docx/style-map.js')
-rw-r--r--lib/docx/style-map.js28
1 files changed, 8 insertions, 20 deletions
diff --git a/lib/docx/style-map.js b/lib/docx/style-map.js
index dcc9f66..5020a87 100644
--- a/lib/docx/style-map.js
+++ b/lib/docx/style-map.js
@@ -1,5 +1,4 @@
var promises = require("../promises");
-var unzip = require("../unzip");
exports.writeStyleMap = writeStyleMap;
exports.readStyleMap = readStyleMap;
@@ -7,25 +6,14 @@ exports.readStyleMap = readStyleMap;
var styleMapPath = "mammoth/style-map";
-function writeStyleMap(options) {
- return promises.when(unzip.openZip(options))
- .then(function(zipFile) {
-
- zipFile.write(styleMapPath, options.styleMap);
-
- return {
- toBuffer: zipFile.toBuffer
- };
- });
+function writeStyleMap(docxFile, styleMap) {
+ docxFile.write(styleMapPath, styleMap);
}
-function readStyleMap(options) {
- return promises.when(unzip.openZip(options))
- .then(function(zipFile) {
- if (zipFile.exists(styleMapPath)) {
- return zipFile.read(styleMapPath, "utf8");
- } else {
- return promises.when(null);
- }
- });
+function readStyleMap(docxFile) {
+ if (docxFile.exists(styleMapPath)) {
+ return docxFile.read(styleMapPath, "utf8");
+ } else {
+ return promises.resolve(null);
+ }
}