xlsx-write-stream
Advanced tools
Comparing version 0.0.13 to 0.0.14
@@ -7,3 +7,3 @@ 'use strict'; | ||
exports.getCellId = getCellId; | ||
exports.escape = escape; | ||
exports.sanitize = sanitize; | ||
exports.timeoutPromised = timeoutPromised; | ||
@@ -23,4 +23,15 @@ const baseString = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; | ||
function escape(text) { | ||
return text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>'); | ||
function sanitize(text) { | ||
const escaped = text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>'); | ||
const sourceBuffer = Buffer.from(escaped); | ||
const buffer = Buffer.alloc(sourceBuffer.byteLength); // allocate enough space | ||
let letter; | ||
let writtenLength = 0; | ||
for (let i = 0; i < escaped.length; i++) { | ||
letter = escaped[i]; | ||
if (letter === '\x09' || letter === '\x0A' || letter === '\x0D' || letter >= '\x20' && letter <= '\uD7FF' || letter >= '\uE000' && letter <= '\uFFFD') { | ||
writtenLength += buffer.write(letter, writtenLength); | ||
} | ||
} | ||
return buffer.toString('utf8', 0, writtenLength); | ||
} | ||
@@ -27,0 +38,0 @@ |
{ | ||
"name": "xlsx-write-stream", | ||
"version": "0.0.13", | ||
"version": "0.0.14", | ||
"description": "Apify xlsx write stream helper", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17591
346