UNPKG

word-math

Version:

Extended version to compatible with OMML of Word Processing Document library

28 lines 873 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); // File meant to be run on its own var fs = require("fs"); var FileType; (function (FileType) { FileType["docx"] = "504b0304"; FileType["docm"] = "504b0304"; FileType["doc"] = "d0cf11e0"; })(FileType || (FileType = {})); function readFile(path) { read(fs.readFileSync(path)); } function read(buffer) { var magicHexAsString = buffer.toString('hex'); if (magicHexAsString.slice(0, FileType.docm.length) == FileType.docm) { console.log("It is a .docm file"); } else if (magicHexAsString.slice(0, FileType.doc.length) == FileType.doc) { console.log("It is a .doc file"); } else { console.log("Unknown file type"); } } var path = './testFiles/test.doc'; readFile(path); //# sourceMappingURL=fileType.js.map