瀏覽代碼

修改引用lodash方法变量名

zhuth 6 年之前
父節點
當前提交
6d76c6eb4e

+ 6 - 6
src/lib/xlsx-populate/ArgHandler.js

@@ -1,9 +1,9 @@
 "use strict";
 
 // const _ = require("lodash");
-const every = require("lodash/every");
-const isNil = require("lodash/isNil");
-const isInteger = require("lodash/isInteger");
+const _every = require("lodash/every");
+const _isNil = require("lodash/isNil");
+const _isInteger = require("lodash/isInteger");
 
 /**
  * Method argument handler. Used for overloading methods.
@@ -64,15 +64,15 @@ class ArgHandler {
     _argsMatchTypes(args, types) {
         if (args.length !== types.length) return false;
 
-        return every(args, (arg, i) => {
+        return _every(args, (arg, i) => {
             const type = types[i];
 
             if (type === '*') return true;
-            if (type === 'nil') return isNil(arg);
+            if (type === 'nil') return _isNil(arg);
             if (type === 'string') return typeof arg === "string";
             if (type === 'boolean') return typeof arg === "boolean";
             if (type === 'number') return typeof arg === "number";
-            if (type === 'integer') return typeof arg === "number" && isInteger(arg);
+            if (type === 'integer') return typeof arg === "number" && _isInteger(arg);
             if (type === 'function') return typeof arg === "function";
             if (type === 'array') return Array.isArray(arg);
             if (type === 'date') return arg && arg.constructor === Date;

+ 21 - 21
src/lib/xlsx-populate/Cell.js

@@ -1,10 +1,10 @@
 "use strict";
 
 // const _ = require("lodash");
-const isNil = require("lodash/isNil");
-const isObject = require("lodash/isObject");
-const isEmpty = require("lodash/isEmpty");
-const isArray = require("lodash/isArray");
+const _isNil = require("lodash/isNil");
+const _isObject = require("lodash/isObject");
+const _isEmpty = require("lodash/isEmpty");
+const _isArray = require("lodash/isArray");
 
 const ArgHandler = require("./ArgHandler");
 const addressConverter = require("./addressConverter");
@@ -94,7 +94,7 @@ class Cell {
         delete this._formulaRef;
 
         // TODO in future version: Move shared formula to some other cell. This would require parsing the formula...
-        if (!isNil(hostSharedFormulaId)) this.sheet().clearCellsUsingSharedFormula(hostSharedFormulaId);
+        if (!_isNil(hostSharedFormulaId)) this.sheet().clearCellsUsingSharedFormula(hostSharedFormulaId);
 
         return this;
     }
@@ -127,7 +127,7 @@ class Cell {
         const value = this.value();
         if (typeof value !== 'string') return false;
 
-        if (isNil(replacement)) {
+        if (_isNil(replacement)) {
             return pattern.test(value);
         } else {
             const replaced = value.replace(pattern, replacement);
@@ -480,7 +480,7 @@ class Cell {
         // Set the address.
         node.attributes.r = this.address();
 
-        if (!isNil(this._formulaType)) {
+        if (!_isNil(this._formulaType)) {
             // Add the formula.
             const fNode = {
                 name: 'f',
@@ -488,12 +488,12 @@ class Cell {
             };
 
             if (this._formulaType !== "normal") fNode.attributes.t = this._formulaType;
-            if (!isNil(this._formulaRef)) fNode.attributes.ref = this._formulaRef;
-            if (!isNil(this._sharedFormulaId)) fNode.attributes.si = this._sharedFormulaId;
-            if (!isNil(this._formula)) fNode.children = [this._formula];
+            if (!_isNil(this._formulaRef)) fNode.attributes.ref = this._formulaRef;
+            if (!_isNil(this._sharedFormulaId)) fNode.attributes.si = this._sharedFormulaId;
+            if (!_isNil(this._formula)) fNode.children = [this._formula];
 
             node.children.push(fNode);
-        } else if (!isNil(this._value)) {
+        } else if (!_isNil(this._value)) {
             // Add the value. Don't emit value if a formula is set as Excel will show this stale value.
             let type, text;
             if (typeof this._value === "string") {
@@ -517,9 +517,9 @@ class Cell {
         }
 
         // If the style is set, set the style ID.
-        if (!isNil(this._style)) {
+        if (!_isNil(this._style)) {
             node.attributes.s = this._style.id();
-        } else if (!isNil(this._styleId)) {
+        } else if (!_isNil(this._styleId)) {
             node.attributes.s = this._styleId;
         }
 
@@ -541,13 +541,13 @@ class Cell {
      * @private
      */
     _init(nodeOrColumnNumber, styleId) {
-        if (isObject(nodeOrColumnNumber)) {
+        if (_isObject(nodeOrColumnNumber)) {
             // Parse the existing node.
             this._parseNode(nodeOrColumnNumber);
         } else {
             // This is a new cell.
             this._columnNumber = nodeOrColumnNumber;
-            if (!isNil(styleId)) this._styleId = styleId;
+            if (!_isNil(styleId)) this._styleId = styleId;
         }
     }
 
@@ -563,7 +563,7 @@ class Cell {
         this._columnNumber = ref.columnNumber;
 
         // Store the style ID if present.
-        if (!isNil(node.attributes.s)) this._styleId = node.attributes.s;
+        if (!_isNil(node.attributes.s)) this._styleId = node.attributes.s;
 
         // Parse the formula if present..
         const fNode = xmlq.findChild(node, 'f');
@@ -573,7 +573,7 @@ class Cell {
             this._formula = fNode.children[0];
 
             this._sharedFormulaId = fNode.attributes.si;
-            if (!isNil(this._sharedFormulaId)) {
+            if (!_isNil(this._sharedFormulaId)) {
                 // Update the sheet's max shared formula ID so we can set future IDs an index beyond this.
                 this.sheet().updateMaxSharedFormulaId(this._sharedFormulaId);
             }
@@ -584,7 +584,7 @@ class Cell {
             delete fNode.attributes.si;
 
             // If any unknown attributes are still present, store them for later output.
-            if (!isEmpty(fNode.attributes)) this._remainingFormulaAttributes = fNode.attributes;
+            if (!_isEmpty(fNode.attributes)) this._remainingFormulaAttributes = fNode.attributes;
         }
 
         // Parse the value.
@@ -597,7 +597,7 @@ class Cell {
                 this._value = this.workbook().sharedStrings().getStringByIndex(sharedIndex);
 
                 // rich text
-                if (isArray(this._value)) {
+                if (_isArray(this._value)) {
                     this._value = new RichText(this._value);
                 }
             } else {
@@ -636,7 +636,7 @@ class Cell {
         delete node.attributes.t;
 
         // If any unknown attributes are still present, store them for later output.
-        if (!isEmpty(node.attributes)) this._remainingAttributes = node.attributes;
+        if (!_isEmpty(node.attributes)) this._remainingAttributes = node.attributes;
 
         // Delete known children.
         xmlq.removeChild(node, 'f');
@@ -644,7 +644,7 @@ class Cell {
         xmlq.removeChild(node, 'is');
 
         // If any unknown children are still present, store them for later output.
-        if (!isEmpty(node.children)) this._remainingChildren = node.children;
+        if (!_isEmpty(node.children)) this._remainingChildren = node.children;
     }
 }
 

+ 2 - 2
src/lib/xlsx-populate/ContentTypes.js

@@ -1,7 +1,7 @@
 "use strict";
 
 // const _ = require("lodash");
-const find = require("lodash/find");
+const _find = require("lodash/find");
 
 /**
  * A content type collection.
@@ -41,7 +41,7 @@ class ContentTypes {
      * @returns {{}|undefined} The matching content type or undefined if not found.
      */
     findByPartName(partName) {
-        return find(this._node.children, node => node.attributes.PartName === partName);
+        return _find(this._node.children, node => node.attributes.PartName === partName);
     }
 
     /**

+ 32 - 32
src/lib/xlsx-populate/Encryptor.js

@@ -9,13 +9,13 @@
  */
 
 // const _ = require("lodash");
-const find = require("lodash/find");
-const cfb = require("cfb");
-const crypto = require("crypto");
-const externals = require("./externals");
-const XmlParser = require("./XmlParser");
-const XmlBuilder = require("./XmlBuilder");
-const xmlq = require("./xmlq");
+const _find = require("lodash/find");
+const _cfb = require("cfb");
+const _crypto = require("crypto");
+const _externals = require("./externals");
+const _XmlParser = require("./XmlParser");
+const _XmlBuilder = require("./XmlBuilder");
+const _xmlq = require("./xmlq");
 
 const ENCRYPTION_INFO_PREFIX = Buffer.from([0x04, 0x00, 0x04, 0x00, 0x40, 0x00, 0x00, 0x00]); // First 4 bytes are the version number, second 4 bytes are reserved.
 const PACKAGE_ENCRYPTION_CHUNK_SIZE = 4096;
@@ -48,14 +48,14 @@ class Encryptor {
     encrypt(data, password) {
         // Generate a random key to use to encrypt the document. Excel uses 32 bytes. We'll use the password to encrypt this key.
         // N.B. The number of bits needs to correspond to an algorithm available in crypto (e.g. aes-256-cbc).
-        const packageKey = crypto.randomBytes(32);
+        const packageKey = _crypto.randomBytes(32);
 
         // Create the encryption info. We'll use this for all of the encryption operations and for building the encryption info XML entry
         const encryptionInfo = {
             package: { // Info on the encryption of the package.
                 cipherAlgorithm: 'AES', // Cipher algorithm to use. Excel uses AES.
                 cipherChaining: 'ChainingModeCBC', // Cipher chaining mode to use. Excel uses CBC.
-                saltValue: crypto.randomBytes(16), // Random value to use as encryption salt. Excel uses 16 bytes.
+                saltValue: _crypto.randomBytes(16), // Random value to use as encryption salt. Excel uses 16 bytes.
                 hashAlgorithm: 'SHA512', // Hash algorithm to use. Excel uses SHA512.
                 hashSize: 64, // The size of the hash in bytes. SHA512 results in 64-byte hashes
                 blockSize: 16, // The number of bytes used to encrypt one block of data. It MUST be at least 2, no greater than 4096, and a multiple of 2. Excel uses 16
@@ -64,7 +64,7 @@ class Encryptor {
             key: { // Info on the encryption of the package key.
                 cipherAlgorithm: 'AES', // Cipher algorithm to use. Excel uses AES.
                 cipherChaining: 'ChainingModeCBC', // Cipher chaining mode to use. Excel uses CBC.
-                saltValue: crypto.randomBytes(16), // Random value to use as encryption salt. Excel uses 16 bytes.
+                saltValue: _crypto.randomBytes(16), // Random value to use as encryption salt. Excel uses 16 bytes.
                 hashAlgorithm: 'SHA512', // Hash algorithm to use. Excel uses SHA512.
                 hashSize: 64, // The size of the hash in bytes. SHA512 results in 64-byte hashes
                 blockSize: 16, // The number of bytes used to encrypt one block of data. It MUST be at least 2, no greater than 4096, and a multiple of 2. Excel uses 16
@@ -91,7 +91,7 @@ class Encryptor {
 
         // Create the data integrity fields used by clients for integrity checks.
         // First generate a random array of bytes to use in HMAC. The docs say to use the same length as the key salt, but Excel seems to use 64.
-        const hmacKey = crypto.randomBytes(64);
+        const hmacKey = _crypto.randomBytes(64);
 
         // Then create an initialization vector using the package encryption info and the appropriate block key.
         const hmacKeyIV = this._createIV(
@@ -161,7 +161,7 @@ class Encryptor {
         /* Verifier hash */
 
         // Create a random byte array for hashing
-        const verifierHashInput = crypto.randomBytes(16);
+        const verifierHashInput = _crypto.randomBytes(16);
 
         // Create an encryption key from the password for the input
         const verifierHashInputKey = this._convertPasswordToKey(
@@ -210,17 +210,17 @@ class Encryptor {
         const encryptionInfoBuffer = this._buildEncryptionInfo(encryptionInfo);
 
         // Create a new CFB
-        let output = cfb.utils.cfb_new();
+        let output = _cfb.utils.cfb_new();
 
         // Add the encryption info and encrypted package
-        cfb.utils.cfb_add(output, "EncryptionInfo", encryptionInfoBuffer);
-        cfb.utils.cfb_add(output, "EncryptedPackage", encryptedPackage);
+        _cfb.utils.cfb_add(output, "EncryptionInfo", encryptionInfoBuffer);
+        _cfb.utils.cfb_add(output, "EncryptedPackage", encryptedPackage);
 
         // Delete the SheetJS entry that is added at initialization
-        cfb.utils.cfb_del(output, "\u0001Sh33tJ5");
+        _cfb.utils.cfb_del(output, "\u0001Sh33tJ5");
 
         // Write to a buffer and return
-        output = cfb.write(output);
+        output = _cfb.write(output);
 
         // The cfb library writes to a Uint8array in the browser. Convert to a Buffer.
         if (!Buffer.isBuffer(output)) output = Buffer.from(output);
@@ -236,15 +236,15 @@ class Encryptor {
      */
     decryptAsync(data, password) {
         // Parse the CFB input and pull out the encryption info and encrypted package entries.
-        const parsed = cfb.parse(data);
-        let encryptionInfoBuffer = find(parsed.FileIndex, { name: "EncryptionInfo" }).content;
-        let encryptedPackageBuffer = find(parsed.FileIndex, { name: "EncryptedPackage" }).content;
+        const parsed = _cfb.parse(data);
+        let encryptionInfoBuffer = _find(parsed.FileIndex, { name: "EncryptionInfo" }).content;
+        let encryptedPackageBuffer = _find(parsed.FileIndex, { name: "EncryptedPackage" }).content;
 
         // In the browser the CFB content is an array. Convert to a Buffer.
         if (!Buffer.isBuffer(encryptionInfoBuffer)) encryptionInfoBuffer = Buffer.from(encryptionInfoBuffer);
         if (!Buffer.isBuffer(encryptedPackageBuffer)) encryptedPackageBuffer = Buffer.from(encryptedPackageBuffer);
 
-        return externals.Promise.resolve()
+        return _externals.Promise.resolve()
             .then(() => this._parseEncryptionInfoAsync(encryptionInfoBuffer)) // Parse the encryption info XML into an object
             .then(encryptionInfo => {
                 // Convert the password into an encryption key
@@ -350,7 +350,7 @@ class Encryptor {
         };
 
         // Convert to an XML string
-        const xmlBuilder = new XmlBuilder();
+        const xmlBuilder = new _XmlBuilder();
         const encryptionInfoXml = xmlBuilder.build(encryptionInfoNode);
 
         // Convert to a buffer and prefix with the appropriate bytes
@@ -368,14 +368,14 @@ class Encryptor {
         const xml = buffer.slice(ENCRYPTION_INFO_PREFIX.length).toString("utf8");
 
         // Parse the XML
-        const xmlParser = new XmlParser();
+        const xmlParser = new _XmlParser();
         return xmlParser.parseAsync(xml)
             .then(doc => {
                 // Pull out the relevant values for decryption and return
-                const keyDataNode = xmlq.findChild(doc, "keyData");
-                const keyEncryptorsNode = xmlq.findChild(doc, "keyEncryptors");
-                const keyEncryptorNode = xmlq.findChild(keyEncryptorsNode, "keyEncryptor");
-                const encryptedKeyNode = xmlq.findChild(keyEncryptorNode, "p:encryptedKey");
+                const keyDataNode = _xmlq.findChild(doc, "keyData");
+                const keyEncryptorsNode = _xmlq.findChild(doc, "keyEncryptors");
+                const keyEncryptorNode = _xmlq.findChild(keyEncryptorsNode, "keyEncryptor");
+                const encryptedKeyNode = _xmlq.findChild(keyEncryptorNode, "p:encryptedKey");
 
                 return {
                     package: {
@@ -407,10 +407,10 @@ class Encryptor {
      */
     _hash(algorithm, ...buffers) {
         algorithm = algorithm.toLowerCase();
-        const hashes = crypto.getHashes();
+        const hashes = _crypto.getHashes();
         if (hashes.indexOf(algorithm) < 0) throw new Error(`Hash algorithm '${algorithm}' not supported!`);
 
-        const hash = crypto.createHash(algorithm);
+        const hash = _crypto.createHash(algorithm);
         hash.update(Buffer.concat(buffers));
         return hash.digest();
     }
@@ -425,10 +425,10 @@ class Encryptor {
      */
     _hmac(algorithm, key, ...buffers) {
         algorithm = algorithm.toLowerCase();
-        const hashes = crypto.getHashes();
+        const hashes = _crypto.getHashes();
         if (hashes.indexOf(algorithm) < 0) throw new Error(`HMAC algorithm '${algorithm}' not supported!`);
 
-        const hmac = crypto.createHmac(algorithm, key);
+        const hmac = _crypto.createHmac(algorithm, key);
         hmac.update(Buffer.concat(buffers));
         return hmac.digest();
     }
@@ -449,7 +449,7 @@ class Encryptor {
         if (cipherChaining === 'ChainingModeCBC') algorithm += '-cbc';
         else throw new Error(`Unknown cipher chaining: ${cipherChaining}`);
 
-        const cipher = crypto[encrypt ? 'createCipheriv' : 'createDecipheriv'](algorithm, key, iv);
+        const cipher = _crypto[encrypt ? 'createCipheriv' : 'createDecipheriv'](algorithm, key, iv);
         cipher.setAutoPadding(false);
         let output = cipher.update(input);
         output = Buffer.concat([output, cipher.final()]);

+ 3 - 3
src/lib/xlsx-populate/Relationships.js

@@ -1,7 +1,7 @@
 "use strict";
 
 // const _ = require("lodash");
-const find = require("lodash/find");
+const _find = require("lodash/find");
 
 
 const RELATIONSHIP_SCHEMA_PREFIX = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/";
@@ -51,7 +51,7 @@ class Relationships {
      * @returns {{}|undefined} The matching relationship or undefined if not found.
      */
     findById(id) {
-        return find(this._node.children, node => node.attributes.Id === id);
+        return _find(this._node.children, node => node.attributes.Id === id);
     }
 
     /**
@@ -60,7 +60,7 @@ class Relationships {
      * @returns {{}|undefined} The matching relationship or undefined if not found.
      */
     findByType(type) {
-        return find(this._node.children, node => node.attributes.Type === `${RELATIONSHIP_SCHEMA_PREFIX}${type}`);
+        return _find(this._node.children, node => node.attributes.Type === `${RELATIONSHIP_SCHEMA_PREFIX}${type}`);
     }
 
     /**

+ 4 - 4
src/lib/xlsx-populate/RichText.js

@@ -1,8 +1,8 @@
 "use strict";
 
 // const _ = require("lodash");
-const includes = require("lodash/includes");
-const cloneDeep = require("lodash/cloneDeep");
+const _includes = require("lodash/includes");
+const _cloneDeep = require("lodash/cloneDeep");
 
 const RichTextFragment = require("./RichTextFragment");
 
@@ -81,8 +81,8 @@ class RichText {
      * @return {RichText} A deep copied instance
      */
     copy(cell) {
-        const newRichText = new RichText(cloneDeep(this.toXml()));
-        if (cell && includes(this.text(), '\n')) {
+        const newRichText = new RichText(_cloneDeep(this.toXml()));
+        if (cell && _includes(this.text(), '\n')) {
             cell.style('wrapText', true);
         }
         return newRichText;

+ 2 - 2
src/lib/xlsx-populate/RichTextFragment.js

@@ -4,7 +4,7 @@
 
 const ArgHandler = require("./ArgHandler");
 // const _ = require("lodash");
-const isEmpty = require("lodash/isEmpty");
+const _isEmpty = require("lodash/isEmpty");
 
 const xmlq = require("./xmlq");
 const colorIndexes = require("./colorIndexes");
@@ -152,7 +152,7 @@ class RichTextFragment {
 
         if (child.attributes.hasOwnProperty('tint')) color.tint = child.attributes.tint;
 
-        if (isEmpty(color)) return;
+        if (_isEmpty(color)) return;
 
         return color;
     }

+ 10 - 10
src/lib/xlsx-populate/Row.js

@@ -1,8 +1,8 @@
 "use strict";
 
-const isNil = require("lodash/isNil");
-const forEach = require("lodash/forEach");
-const findIndex = require("lodash/findIndex");
+const _isNil = require("lodash/isNil");
+const _forEach = require("lodash/forEach");
+const _findIndex = require("lodash/findIndex");
 const Cell = require("./Cell");
 const regexify = require("./regexify");
 const ArgHandler = require("./ArgHandler");
@@ -63,8 +63,8 @@ class Row {
         const columnStyleId = this.sheet().existingColumnStyleId(columnNumber);
 
         // Row style takes priority. If a cell has both row and column styles it should have created a cell entry with a cell-specific style.
-        if (!isNil(rowStyleId)) styleId = rowStyleId;
-        else if (!isNil(columnStyleId)) styleId = columnStyleId;
+        if (!_isNil(rowStyleId)) styleId = rowStyleId;
+        else if (!_isNil(columnStyleId)) styleId = columnStyleId;
 
         // Create the new cell.
         const cell = new Cell(this, columnNumber, styleId);
@@ -177,7 +177,7 @@ class Row {
                 this._createCellStylesIfNeeded();
 
                 // Style each existing cell within this row. (Cells don't inherit ow/column styles.)
-                forEach(this._cells, cell => {
+                _forEach(this._cells, cell => {
                     if (cell) cell.style(name, value);
                 });
 
@@ -201,7 +201,7 @@ class Row {
                 this._createCellStylesIfNeeded();
 
                 // Style each existing cell within this row. (Cells don't inherit ow/column styles.)
-                forEach(this._cells, cell => {
+                _forEach(this._cells, cell => {
                     if (cell) cell.style(style);
                 });
 
@@ -282,7 +282,7 @@ class Row {
      * @ignore
      */
     hasStyle() {
-        return isNil(this._node.attributes.s);
+        return _isNil(this._node.attributes.s);
     }
 
     /**
@@ -291,7 +291,7 @@ class Row {
      * @ignore
      */
     minUsedColumnNumber() {
-        return findIndex(this._cells);
+        return _findIndex(this._cells);
     }
 
     /**
@@ -323,7 +323,7 @@ class Row {
      */
     _createCellStylesIfNeeded() {
         this.sheet().forEachExistingColumnNumber(columnNumber => {
-            if (!isNil(this.sheet().existingColumnStyleId(columnNumber))) this.cell(columnNumber);
+            if (!_isNil(this.sheet().existingColumnStyleId(columnNumber))) this.cell(columnNumber);
         });
     }
 

+ 3 - 3
src/lib/xlsx-populate/SharedStrings.js

@@ -1,7 +1,7 @@
 "use strict";
 
 // const _ = require("lodash");
-const isArray = require("lodash/isArray");
+const _isArray = require("lodash/isArray");
 
 /**
  * The shared strings table.
@@ -27,7 +27,7 @@ class SharedStrings {
      */
     getIndexForString(string) {
         // If the string is found in the cache, return the index.
-        const key = isArray(string) ? JSON.stringify(string) : string;
+        const key = _isArray(string) ? JSON.stringify(string) : string;
         let index = this._indexMap[key];
         if (index >= 0) return index;
 
@@ -39,7 +39,7 @@ class SharedStrings {
         // Append a new si node.
         this._node.children.push({
             name: "si",
-            children: isArray(string) ? string : [
+            children: _isArray(string) ? string : [
                 {
                     name: "t",
                     attributes: { 'xml:space': "preserve" },

+ 36 - 36
src/lib/xlsx-populate/Sheet.js

@@ -1,18 +1,18 @@
 "use strict";
 
 // const _ = require("lodash");
-const cloneDeep = require("lodash/cloneDeep");
-const filter = require("lodash/filter");
-const findIndex = require("lodash/findIndex");
-const forEach = require("lodash/forEach");
-const clone = require("lodash/clone");
-const values = require("lodash/values");
-const assign = require("lodash/assign");
-const isEqual = require("lodash/isEqual");
-const sortBy = require("lodash/sortBy");
-const isNaN = require("lodash/isNaN");
-const includes = require("lodash/includes");
-const isNumber = require("lodash/isNumber");
+const _cloneDeep = require("lodash/cloneDeep");
+const _filter = require("lodash/filter");
+const _findIndex = require("lodash/findIndex");
+const _forEach = require("lodash/forEach");
+const _clone = require("lodash/clone");
+const _values = require("lodash/values");
+const _assign = require("lodash/assign");
+const _isEqual = require("lodash/isEqual");
+const _sortBy = require("lodash/sortBy");
+const _isNaN = require("lodash/isNaN");
+const _includes = require("lodash/includes");
+const _isNumber = require("lodash/isNumber");
 
 const Cell = require("./Cell");
 const Row = require("./Row");
@@ -162,7 +162,7 @@ class Sheet {
             // If the existing node covered earlier columns than the new one, we need to have a col node to cover the min up to our new node.
             if (existingColNode.attributes.min < columnNumber) {
                 // Clone the node and set the max to the column before our new col.
-                const beforeColNode = cloneDeep(existingColNode);
+                const beforeColNode = _cloneDeep(existingColNode);
                 beforeColNode.attributes.max = columnNumber - 1;
 
                 // Update the col nodes cache.
@@ -172,14 +172,14 @@ class Sheet {
             }
 
             // Make a clone for the new column. Set the min/max to the column number and cache it.
-            colNode = cloneDeep(existingColNode);
+            colNode = _cloneDeep(existingColNode);
             colNode.attributes.min = columnNumber;
             colNode.attributes.max = columnNumber;
             this._colNodes[columnNumber] = colNode;
 
             // If the max of the existing node is greater than the nre one, create a col node for that too.
             if (existingColNode.attributes.max > columnNumber) {
-                const afterColNode = cloneDeep(existingColNode);
+                const afterColNode = _cloneDeep(existingColNode);
                 afterColNode.attributes.min = columnNumber + 1;
                 for (let i = afterColNode.attributes.min; i <= afterColNode.attributes.max; i++) {
                     this._colNodes[i] = afterColNode;
@@ -292,7 +292,7 @@ class Sheet {
             })
             .case('*', hidden => {
                 if (hidden) {
-                    const visibleSheets = filter(this.workbook().sheets(), sheet => !sheet.hidden());
+                    const visibleSheets = _filter(this.workbook().sheets(), sheet => !sheet.hidden());
                     if (visibleSheets.length === 1 && visibleSheets[0] === this) {
                         throw new Error("This sheet may not be hidden as a workbook must contain at least one visible sheet.");
                     }
@@ -483,7 +483,7 @@ class Sheet {
      * @returns {Range|undefined} The used range or undefined if no cells in the sheet are used.
      */
     usedRange() {
-        const minRowNumber = findIndex(this._rows);
+        const minRowNumber = _findIndex(this._rows);
         const maxRowNumber = this._rows.length - 1;
 
         let minColumnNumber = 0;
@@ -570,7 +570,7 @@ class Sheet {
      * @ignore
      */
     forEachExistingColumnNumber(callback) {
-        forEach(this._colNodes, (node, columnNumber) => {
+        _forEach(this._colNodes, (node, columnNumber) => {
             if (!node) return;
             callback(columnNumber);
         });
@@ -583,7 +583,7 @@ class Sheet {
      * @ignore
      */
     forEachExistingRow(callback) {
-        forEach(this._rows, (row, rowNumber) => {
+        _forEach(this._rows, (row, rowNumber) => {
             if (row) callback(row, rowNumber);
         });
 
@@ -841,11 +841,11 @@ class Sheet {
      */
     toXmls() {
         // Shallow clone the node so we don't have to remove these children later if they don't belong.
-        const node = clone(this._node);
+        const node = _clone(this._node);
         node.children = node.children.slice();
 
         // Add the columns if needed.
-        this._colsNode.children = filter(this._colNodes, (colNode, i) => {
+        this._colsNode.children = _filter(this._colNodes, (colNode, i) => {
             // Columns should only be present if they have attributes other than min/max.
             return colNode && i === colNode.attributes.min && Object.keys(colNode.attributes).length > 2;
         });
@@ -854,7 +854,7 @@ class Sheet {
         }
 
         // Add the hyperlinks if needed.
-        this._hyperlinksNode.children = values(this._hyperlinks);
+        this._hyperlinksNode.children = _values(this._hyperlinks);
         if (this._hyperlinksNode.children.length) {
             xmlq.insertInOrder(node, this._hyperlinksNode, nodeOrder);
         }
@@ -869,10 +869,10 @@ class Sheet {
         // Add the pageMargins if needed.
         if (this._pageMarginsNode && this._pageMarginsPresetName) {
             // Clone to preserve the current state of this sheet.
-            const childNode = clone(this._pageMarginsNode);
+            const childNode = _clone(this._pageMarginsNode);
             if (Object.keys(this._pageMarginsNode.attributes).length) {
                 // Fill in any missing attribute values with presets.
-                childNode.attributes = assign(
+                childNode.attributes = _assign(
                     this._pageMarginsPresets[this._pageMarginsPresetName],
                     this._pageMarginsNode.attributes);
             } else {
@@ -883,13 +883,13 @@ class Sheet {
         }
 
         // Add the merge cells if needed.
-        this._mergeCellsNode.children = values(this._mergeCells);
+        this._mergeCellsNode.children = _values(this._mergeCells);
         if (this._mergeCellsNode.children.length) {
             xmlq.insertInOrder(node, this._mergeCellsNode, nodeOrder);
         }
 
         // Add the DataValidation cells if needed.
-        this._dataValidationsNode.children = values(this._dataValidations);
+        this._dataValidationsNode.children = _values(this._dataValidations);
         if (this._dataValidationsNode.children.length) {
             xmlq.insertInOrder(node, this._dataValidationsNode, nodeOrder);
         }
@@ -1104,17 +1104,17 @@ class Sheet {
                 // Validate preset attribute keys.
                 const pageMarginsAttributeNames = [
                     'left', 'right', 'top', 'bottom', 'header', 'footer'];
-                const isValidPresetAttributeKeys = isEqual(
-                    sortBy(pageMarginsAttributeNames),
-                    sortBy(Object.keys(presetAttributes)));
+                const isValidPresetAttributeKeys = _isEqual(
+                    _sortBy(pageMarginsAttributeNames),
+                    _sortBy(Object.keys(presetAttributes)));
                 if (isValidPresetAttributeKeys === false) {
                     throw new Error(`Sheet.pageMarginsPreset: Invalid preset attributes for one or key(s)! - "${Object.keys(presetAttributes)}"`);
                 }
 
                 // Validate preset attribute values.
-                forEach((attributeValue, attributeName) => {
+                _forEach((attributeValue, attributeName) => {
                     const attributeNumberValue = parseFloat(attributeValue);
-                    if (isNaN(attributeNumberValue) || isNumber(attributeNumberValue) === false) {
+                    if (_isNaN(attributeNumberValue) || _isNumber(attributeNumberValue) === false) {
                         throw new Error(`Sheet.pageMarginsPreset: Invalid preset attribute value! - "${attributeValue}"`);
                     }
                 });
@@ -1162,7 +1162,7 @@ class Sheet {
         return new ArgHandler('Sheet.pane')
             .case(() => {
                 if (paneNode) {
-                    const result = cloneDeep(paneNode.attributes);
+                    const result = _cloneDeep(paneNode.attributes);
                     if (!result.state) result.state = 'split';
                     return result;
                 }
@@ -1172,7 +1172,7 @@ class Sheet {
                 return this;
             })
             .case(['object'], paneAttributes => {
-                const attributes = assign({ activePane: 'bottomRight' }, paneAttributes);
+                const attributes = _assign({ activePane: 'bottomRight' }, paneAttributes);
                 checkStateName(attributes.state);
                 checkActivePane(attributes.activePane);
                 if (paneNode) {
@@ -1250,7 +1250,7 @@ class Sheet {
      */
     _getCheckAttributeNameHelper(functionName, supportedAttributeNames) {
         return attributeName => {
-            if (!includes(supportedAttributeNames, attributeName)) {
+            if (!_includes(supportedAttributeNames, attributeName)) {
                 throw new Error(`Sheet.${functionName}: "${attributeName}" is not supported.`);
             }
         };
@@ -1385,7 +1385,7 @@ class Sheet {
 
         // Cache the col nodes.
         this._colNodes = [];
-        forEach(this._colsNode.children, colNode => {
+        _forEach(this._colsNode.children, colNode => {
             const min = colNode.attributes.min;
             const max = colNode.attributes.max;
             for (let i = min; i <= max; i++) {
@@ -1488,7 +1488,7 @@ class Sheet {
 
             // Search for a preset that matches existing attributes.
             for (const presetName in this._pageMarginsPresets) {
-                if (isEqual(this._pageMarginsNode.attributes, this._pageMarginsPresets[presetName])) {
+                if (_isEqual(this._pageMarginsNode.attributes, this._pageMarginsPresets[presetName])) {
                     this._pageMarginsPresetName = presetName;
                     break;
                 }

+ 23 - 23
src/lib/xlsx-populate/Style.js

@@ -4,14 +4,14 @@
 
 const ArgHandler = require("./ArgHandler");
 // const _ = require("lodash");
-const isEmpty = require("lodash/isEmpty");
-const map = require("lodash/map");
-const isNil = require("lodash/isNil");
-const forEach = require("lodash/forEach");
-const isObject = require("lodash/isObject");
-const forOwn = require("lodash/forOwn");
-const defaults = require("lodash/defaults");
-const mapValues = require("lodash/mapValues");
+const _isEmpty = require("lodash/isEmpty");
+const _map = require("lodash/map");
+const _isNil = require("lodash/isNil");
+const _forEach = require("lodash/forEach");
+const _isObject = require("lodash/isObject");
+const _forOwn = require("lodash/forOwn");
+const _defaults = require("lodash/defaults");
+const _mapValues = require("lodash/mapValues");
 
 const xmlq = require("./xmlq");
 const colorIndexes = require("./colorIndexes");
@@ -81,7 +81,7 @@ class Style {
 
         if (child.attributes.hasOwnProperty('tint')) color.tint = child.attributes.tint;
 
-        if (isEmpty(color)) return;
+        if (_isEmpty(color)) return;
 
         return color;
     }
@@ -370,7 +370,7 @@ class Style {
             const fill = {
                 type: "gradient",
                 gradientType,
-                stops: map(gradientFillNode.children, stop => ({
+                stops: _map(gradientFillNode.children, stop => ({
                     position: stop.attributes.position,
                     color: this._getColor(stop, "color")
                 }))
@@ -393,7 +393,7 @@ class Style {
         this._fillNode.children = [];
 
         // No fill
-        if (isNil(fill)) return;
+        if (_isNil(fill)) return;
 
         // Pattern fill
         if (fill.type === "pattern") {
@@ -421,7 +421,7 @@ class Style {
                 degree: fill.angle
             });
 
-            forEach(fill.stops, (fillStop, i) => {
+            _forEach(fill.stops, (fillStop, i) => {
                 const stop = {
                     name: 'stop',
                     attributes: { position: fillStop.position },
@@ -435,7 +435,7 @@ class Style {
         }
 
         // Solid fill (really a pattern fill with a solid pattern type).
-        if (!isObject(fill)) fill = { type: "solid", color: fill };
+        if (!_isObject(fill)) fill = { type: "solid", color: fill };
         else if (fill.hasOwnProperty('rgb') || fill.hasOwnProperty("theme")) fill = { color: fill };
 
         const patternFill = {
@@ -467,14 +467,14 @@ class Style {
                 if (direction) sideResult.direction = direction;
             }
 
-            if (!isEmpty(sideResult)) result[side] = sideResult;
+            if (!_isEmpty(sideResult)) result[side] = sideResult;
         });
 
         return result;
     }
 
     _setBorder(settings) {
-        forOwn(settings, (setting, side) => {
+        _forOwn(settings, (setting, side) => {
             if (typeof setting === "boolean") {
                 setting = { style: setting ? "thin" : null };
             } else if (typeof setting === "string") {
@@ -506,8 +506,8 @@ class Style {
     }
 
     _set_border(settings) {
-        if (isObject(settings) && !settings.hasOwnProperty("style") && !settings.hasOwnProperty("color")) {
-            settings = defaults(settings, {
+        if (_isObject(settings) && !settings.hasOwnProperty("style") && !settings.hasOwnProperty("color")) {
+            settings = _defaults(settings, {
                 left: null,
                 right: null,
                 top: null,
@@ -526,12 +526,12 @@ class Style {
     }
 
     _get_borderColor() {
-        return mapValues(this._getBorder(), value => value.color);
+        return _mapValues(this._getBorder(), value => value.color);
     }
 
     _set_borderColor(color) {
-        if (isObject(color)) {
-            this._setBorder(mapValues(color, color => ({ color })));
+        if (_isObject(color)) {
+            this._setBorder(_mapValues(color, color => ({ color })));
         } else {
             this._setBorder({
                 left: { color },
@@ -544,12 +544,12 @@ class Style {
     }
 
     _get_borderStyle() {
-        return mapValues(this._getBorder(), value => value.style);
+        return _mapValues(this._getBorder(), value => value.style);
     }
 
     _set_borderStyle(style) {
-        if (isObject(style)) {
-            this._setBorder(mapValues(style, style => ({ style })));
+        if (_isObject(style)) {
+            this._setBorder(_mapValues(style, style => ({ style })));
         } else {
             this._setBorder({
                 left: { style },

+ 7 - 7
src/lib/xlsx-populate/StyleSheet.js

@@ -1,8 +1,8 @@
 "use strict";
 
 // const _ = require("lodash");
-const cloneDeep = require("lodash/cloneDeep");
-const assign = require("lodash/assign");
+const _cloneDeep = require("lodash/cloneDeep");
+const _assign = require("lodash/assign");
 
 const xmlq = require("./xmlq");
 const Style = require("./Style");
@@ -72,21 +72,21 @@ class StyleSheet {
         let fontNode, fillNode, borderNode, xfNode;
         if (sourceId >= 0) {
             const sourceXfNode = this._cellXfsNode.children[sourceId];
-            xfNode = cloneDeep(sourceXfNode);
+            xfNode = _cloneDeep(sourceXfNode);
 
             if (sourceXfNode.attributes.applyFont) {
                 const fontId = sourceXfNode.attributes.fontId;
-                fontNode = cloneDeep(this._fontsNode.children[fontId]);
+                fontNode = _cloneDeep(this._fontsNode.children[fontId]);
             }
 
             if (sourceXfNode.attributes.applyFill) {
                 const fillId = sourceXfNode.attributes.fillId;
-                fillNode = cloneDeep(this._fillsNode.children[fillId]);
+                fillNode = _cloneDeep(this._fillsNode.children[fillId]);
             }
 
             if (sourceXfNode.attributes.applyBorder) {
                 const borderId = sourceXfNode.attributes.borderId;
-                borderNode = cloneDeep(this._bordersNode.children[borderId]);
+                borderNode = _cloneDeep(this._bordersNode.children[borderId]);
             }
         }
 
@@ -108,7 +108,7 @@ class StyleSheet {
         this._bordersNode.children.push(borderNode);
 
         if (!xfNode) xfNode = { name: "xf", attributes: {}, children: [] };
-        assign(xfNode.attributes, {
+        _assign(xfNode.attributes, {
             fontId: this._fontsNode.children.length - 1,
             fillId: this._fillsNode.children.length - 1,
             borderId: this._bordersNode.children.length - 1,

+ 27 - 27
src/lib/xlsx-populate/Workbook.js

@@ -1,15 +1,15 @@
 "use strict";
 
 // const _ = require("lodash");
-const forEach = require("lodash/forEach");
-const filter = require("lodash/filter");
-const isNil = require("lodash/isNil");
-const isInteger = require("lodash/isInteger");
-const find = require("lodash/find");
-const isFunction = require("lodash/isFunction");
-const forOwn = require("lodash/forOwn");
-const some = require("lodash/some");
-const map = require("lodash/map");
+const _forEach = require("lodash/forEach");
+const _filter = require("lodash/filter");
+const _isNil = require("lodash/isNil");
+const _isInteger = require("lodash/isInteger");
+const _find = require("lodash/find");
+const _isFunction = require("lodash/isFunction");
+const _forOwn = require("lodash/forOwn");
+const _some = require("lodash/some");
+const _map = require("lodash/map");
 
 const fs = require("fs");
 const JSZip = require('jszip');
@@ -120,7 +120,7 @@ class Workbook {
                 if (sheet.hidden()) throw new Error("You may not activate a hidden sheet.");
 
                 // Deselect all sheets except the active one (mirroring ying Excel behavior).
-                forEach(this._sheets, current => {
+                _forEach(this._sheets, current => {
                     current.tabSelected(current === sheet);
                 });
 
@@ -176,7 +176,7 @@ class Workbook {
         }
 
         // Make sure we are not deleting the only visible sheet.
-        const visibleSheets = filter(this._sheets, sheet => !sheet.hidden());
+        const visibleSheets = _filter(this._sheets, sheet => !sheet.hidden());
         if (visibleSheets.length === 1 && visibleSheets[0] === sheet) {
             throw new Error("This sheet may not be deleted as a workbook must contain at least one visible sheet.");
         }
@@ -227,9 +227,9 @@ class Workbook {
         // Get the to/from indexes.
         const from = this._sheets.indexOf(sheet);
         let to;
-        if (isNil(indexOrBeforeSheet)) {
+        if (_isNil(indexOrBeforeSheet)) {
             to = this._sheets.length - 1;
-        } else if (isInteger(indexOrBeforeSheet)) {
+        } else if (_isInteger(indexOrBeforeSheet)) {
             to = indexOrBeforeSheet;
         } else {
             if (!(indexOrBeforeSheet instanceof Sheet)) {
@@ -338,8 +338,8 @@ class Workbook {
      * @returns {Sheet|undefined} The sheet or undefined if not found.
      */
     sheet(sheetNameOrIndex) {
-        if (isInteger(sheetNameOrIndex)) return this._sheets[sheetNameOrIndex];
-        return find(this._sheets, sheet => sheet.name() === sheetNameOrIndex);
+        if (_isInteger(sheetNameOrIndex)) return this._sheets[sheetNameOrIndex];
+        return _find(this._sheets, sheet => sheet.name() === sheetNameOrIndex);
     }
 
     /**
@@ -443,7 +443,7 @@ class Workbook {
      */
     scopedDefinedName(sheetScope, name, refersTo) {
         let definedNamesNode = xmlq.findChild(this._node, "definedNames");
-        let definedNameNode = definedNamesNode && find(definedNamesNode.children, node => node.attributes.name === name && node.localSheet === sheetScope);
+        let definedNameNode = definedNamesNode && _find(definedNamesNode.children, node => node.attributes.name === name && node.localSheet === sheetScope);
 
         return new ArgHandler('Workbook.scopedDefinedName')
             .case(['*', 'string'], () => {
@@ -538,7 +538,7 @@ class Workbook {
         return this._addSheet(name, indexOrBeforeSheet, () => {
             const cloneXml = node => {
                 // If the node has a toXml method, call it.
-                if (node && isFunction(node.toXml)) node = node.toXml();
+                if (node && _isFunction(node.toXml)) node = node.toXml();
         
                 if (typeof node === 'object') {
                     if (node.name) {
@@ -548,7 +548,7 @@ class Workbook {
                             children: []
                         };
                         
-                        forOwn(node.attributes, (value, name) => {
+                        _forOwn(node.attributes, (value, name) => {
                             result.attributes[name] = value;
                         }); 
                     
@@ -588,15 +588,15 @@ class Workbook {
     _addSheet(name, indexOrBeforeSheet, getTemplateNodes) {
         // Validate the sheet name.
         if (!name || typeof name !== "string") throw new Error("Invalid sheet name.");
-        if (some(badSheetNameChars, char => name.indexOf(char) >= 0)) throw new Error(`Sheet name may not contain any of the following characters: ${badSheetNameChars.join(" ")}`);
+        if (_some(badSheetNameChars, char => name.indexOf(char) >= 0)) throw new Error(`Sheet name may not contain any of the following characters: ${badSheetNameChars.join(" ")}`);
         if (name.length > maxSheetNameLength) throw new Error(`Sheet name may not be greater than ${maxSheetNameLength} characters.`);
         if (this.sheet(name)) throw new Error(`Sheet with name "${name}" already exists.`);
 
         // Get the destination index of new sheet.
         let index;
-        if (isNil(indexOrBeforeSheet)) {
+        if (_isNil(indexOrBeforeSheet)) {
             index = this._sheets.length;
-        } else if (isInteger(indexOrBeforeSheet)) {
+        } else if (_isInteger(indexOrBeforeSheet)) {
             index = indexOrBeforeSheet;
         } else {
             if (!(indexOrBeforeSheet instanceof Sheet)) {
@@ -709,7 +709,7 @@ class Workbook {
 
                 // Load each sheet.
                 this._sheetsNode = xmlq.findChild(this._node, "sheets");
-                return externals.Promise.all(map(this._sheetsNode.children, (sheetIdNode, i) => {
+                return externals.Promise.all(_map(this._sheetsNode.children, (sheetIdNode, i) => {
                     if (sheetIdNode.attributes.sheetId > this._maxSheetId) this._maxSheetId = sheetIdNode.attributes.sheetId;
 
                     return this._parseNodesAsync([`xl/worksheets/sheet${i + 1}.xml`, `xl/worksheets/_rels/sheet${i + 1}.xml.rels`])
@@ -733,9 +733,9 @@ class Workbook {
      * @private
      */
     _parseNodesAsync(names) {
-        return externals.Promise.all(map(names, name => this._zip.file(name)))
-            .then(files => externals.Promise.all(map(files, file => file && file.async("string"))))
-            .then(texts => externals.Promise.all(map(texts, text => text && xmlParser.parseAsync(text))));
+        return externals.Promise.all(_map(names, name => this._zip.file(name)))
+            .then(files => externals.Promise.all(_map(files, file => file && file.async("string"))))
+            .then(texts => externals.Promise.all(_map(texts, text => text && xmlParser.parseAsync(text))));
     }
 
     /**
@@ -754,7 +754,7 @@ class Workbook {
         // but reordering sheets messes this up. So store it on the node and we'll update the index on XML build.
         const definedNamesNode = xmlq.findChild(this._node, "definedNames");
         if (definedNamesNode) {
-            forEach(definedNamesNode.children, definedNameNode => {
+            _forEach(definedNamesNode.children, definedNameNode => {
                 if (definedNameNode.attributes.hasOwnProperty("localSheetId")) {
                     definedNameNode.localSheet = this._sheets[definedNameNode.attributes.localSheetId];
                 }
@@ -786,7 +786,7 @@ class Workbook {
         // Set the defined names local sheet indexes.
         const definedNamesNode = xmlq.findChild(this._node, "definedNames");
         if (definedNamesNode) {
-            forEach(definedNamesNode.children, definedNameNode => {
+            _forEach(definedNamesNode.children, definedNameNode => {
                 if (definedNameNode.localSheet) {
                     definedNameNode.attributes.localSheetId = this._sheets.indexOf(definedNameNode.localSheet);
                 }

+ 13 - 14
src/lib/xlsx-populate/XmlBuilder.js

@@ -1,13 +1,12 @@
 "use strict";
 
 // const _ = require("lodash");
-const isFunction = require("lodash/isFunction");
-const isObject = require("lodash/isObject");
-const forOwn = require("lodash/forOwn");
-const isEmpty = require("lodash/isEmpty");
-const forEach = require("lodash/forEach");
-const isNil = require("lodash/isNil");
-const find = require("lodash/find");
+const _isFunction = require("lodash/isFunction");
+const _isObject = require("lodash/isObject");
+const _forOwn = require("lodash/forOwn");
+const _isEmpty = require("lodash/isEmpty");
+const _forEach = require("lodash/forEach");
+const _isNil = require("lodash/isNil");
 
 
 const XML_DECLARATION = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>`;
@@ -47,9 +46,9 @@ class XmlBuilder {
         }
 
         // If the node has a toXml method, call it.
-        if (node && isFunction(node.toXml)) node = node.toXml();
+        if (node && _isFunction(node.toXml)) node = node.toXml();
 
-        if (isObject(node)) {
+        if (_isObject(node)) {
             // If the node is an object, then it maps to an element. Check if it has a name.
             if (!node.name) throw new Error(`XML node does not have name: ${JSON.stringify(node)}`);
 
@@ -57,18 +56,18 @@ class XmlBuilder {
             xml += `<${node.name}`;
 
             // Add any node attributes
-            forOwn(node.attributes, (value, name) => {
+            _forOwn(node.attributes, (value, name) => {
                 xml += ` ${name}="${this._escapeString(value, true)}"`;
             });
 
-            if (isEmpty(node.children)) {
+            if (_isEmpty(node.children)) {
                 // Self-close the tag if no children.
                 xml += "/>";
             } else {
                 xml += ">";
                 
                 // Recursively add any children.
-                forEach(node.children, child => {
+                _forEach(node.children, child => {
                     // Add the children to the XML.
                     xml = this._build(child, xml);
                 });
@@ -76,7 +75,7 @@ class XmlBuilder {
                 // Close the tag.
                 xml += `</${node.name}>`;
             }
-        } else if (!isNil(node)) {
+        } else if (!_isNil(node)) {
             // It not an object, this should be a text node. Just add it.
             xml += this._escapeString(node);
         }
@@ -93,7 +92,7 @@ class XmlBuilder {
      * @private
      */
     _escapeString(value, isAttribute) {
-        if (isNil(value)) return value;
+        if (_isNil(value)) return value;
         value = value.toString()
             .replace(/&/g, "&amp;") // Escape '&' first as the other escapes add them.
             .replace(/</g, "&lt;")

+ 2 - 2
src/lib/xlsx-populate/regexify.js

@@ -1,7 +1,7 @@
 "use strict";
 
 // const _ = require("lodash");
-const escapeRegExp = require("lodash/escapeRegExp");
+const _escapeRegExp = require("lodash/escapeRegExp");
 
 /**
  * Convert a pattern to a RegExp.
@@ -11,7 +11,7 @@ const escapeRegExp = require("lodash/escapeRegExp");
  */
 module.exports = pattern => {
     if (typeof pattern === "string") {
-        pattern = new RegExp(escapeRegExp(pattern), "igm");
+        pattern = new RegExp(_escapeRegExp(pattern), "igm");
     }
 
     pattern.lastIndex = 0;

+ 14 - 14
src/lib/xlsx-populate/xmlq.js

@@ -1,12 +1,12 @@
 "use strict";
 
 // const _ = require("lodash");
-const find = require("lodash/find");
-const some = require("lodash/some");
-const isEmpty = require("lodash/isEmpty");
-const remove = require("lodash/remove");
-const isNil = require("lodash/isNil");
-const forOwn = require("lodash/forOwn");
+const _find = require("lodash/find");
+const _some = require("lodash/some");
+const _isEmpty = require("lodash/isEmpty");
+const _remove = require("lodash/remove");
+const _isNil = require("lodash/isNil");
+const _forOwn = require("lodash/forOwn");
 
 /**
  * XML query methods.
@@ -47,7 +47,7 @@ module.exports = {
      * @returns {undefined|{}} The child if found.
      */
     findChild(node, name) {
-        return find(node.children, { name });
+        return _find(node.children, { name });
     },
 
     /**
@@ -69,7 +69,7 @@ module.exports = {
      * @returns {boolean} True if found, false otherwise.
      */
     hasChild(node, name) {
-        return some(node.children, { name });
+        return _some(node.children, { name });
     },
 
     /**
@@ -126,7 +126,7 @@ module.exports = {
      * @returns {boolean} True if empty, false otherwise.
      */
     isEmpty(node) {
-        return isEmpty(node.children) && isEmpty(node.attributes);
+        return _isEmpty(node.children) && _isEmpty(node.attributes);
     },
 
     /**
@@ -138,7 +138,7 @@ module.exports = {
     removeChild(node, child) {
         if (!node.children) return;
         if (typeof child === 'string') {
-            remove(node.children, { name: child });
+            _remove(node.children, { name: child });
         } else {
             const index = node.children.indexOf(child);
             if (index >= 0) node.children.splice(index, 1);
@@ -152,8 +152,8 @@ module.exports = {
      * @returns {undefined}
      */
     setAttributes(node, attributes) {
-        forOwn(attributes, (value, attribute) => {
-            if (isNil(value)) {
+        _forOwn(attributes, (value, attribute) => {
+            if (_isNil(value)) {
                 if (node.attributes) delete node.attributes[attribute];
             } else {
                 if (!node.attributes) node.attributes = {};
@@ -171,8 +171,8 @@ module.exports = {
      */
     setChildAttributes(node, name, attributes) {
         let child = this.findChild(node, name);
-        forOwn(attributes, (value, attribute) => {
-            if (isNil(value)) {
+        _forOwn(attributes, (value, attribute) => {
+            if (_isNil(value)) {
                 if (child && child.attributes) delete child.attributes[attribute];
             } else {
                 if (!child) {