csv-stringify
Advanced tools
Comparing version 5.3.3 to 5.3.4
# Changelog | ||
## Version 5.3.4 | ||
* src: strengthen conditions | ||
* test: ensure every sample is valid | ||
* package: contributing | ||
* package: code of conduct | ||
* quoted_match: ts types string or RegExp | ||
## Version 5.3.3 | ||
@@ -5,0 +13,0 @@ |
@@ -79,5 +79,5 @@ /// <reference types="node" /> | ||
/** | ||
* Boolean, default to false, quote all fields matching a regular expression. | ||
* String or RegExp, no default, quote all fields matching a regular expression. | ||
*/ | ||
quoted_match?: boolean | ||
quoted_match?: string | RegExp | ||
/** | ||
@@ -84,0 +84,0 @@ * Boolean, default to false, quote all fields of type string even if not required. |
@@ -11,3 +11,3 @@ "use strict"; | ||
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
@@ -49,3 +49,3 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
// stream. | ||
// Refers to the [official prject documentation](http://csv.adaltas.com/stringify/) | ||
// Refers to the [official prject documentation](http://csv.js.org/stringify/) | ||
// on how to call this function. | ||
@@ -584,5 +584,5 @@ | ||
quotedMatch = quotedMatch && quotedMatch.length > 0; | ||
shouldQuote = containsQuote || containsdelimiter || containsRowDelimiter || quoted || quotedString || quotedMatch; | ||
shouldQuote = containsQuote === true || containsdelimiter || containsRowDelimiter || quoted || quotedString || quotedMatch; | ||
if (shouldQuote && containsEscape) { | ||
if (shouldQuote === true && containsEscape === true) { | ||
regexp = escape === '\\' ? new RegExp(escape + escape, 'g') : new RegExp(escape, 'g'); | ||
@@ -592,3 +592,3 @@ value = value.replace(regexp, escape + escape); | ||
if (containsQuote) { | ||
if (containsQuote === true) { | ||
regexp = new RegExp(quote, 'g'); | ||
@@ -598,3 +598,3 @@ value = value.replace(regexp, escape + quote); | ||
if (shouldQuote) { | ||
if (shouldQuote === true) { | ||
value = quote + value + quote; | ||
@@ -604,3 +604,3 @@ } | ||
csvrecord += value; | ||
} else if (quoted_empty || quoted_empty == null && field === '' && quoted_string) { | ||
} else if (quoted_empty === true || quoted_empty == null && field === '' && quoted_string !== false) { | ||
csvrecord += quote + quote; | ||
@@ -607,0 +607,0 @@ } |
@@ -79,5 +79,5 @@ /// <reference types="node" /> | ||
/** | ||
* Boolean, default to false, quote all fields matching a regular expression. | ||
* String or RegExp, no default, quote all fields matching a regular expression. | ||
*/ | ||
quoted_match?: boolean | ||
quoted_match?: string | RegExp | ||
/** | ||
@@ -84,0 +84,0 @@ * Boolean, default to false, quote all fields of type string even if not required. |
@@ -17,3 +17,3 @@ // Generated by CoffeeScript 2.4.1 | ||
// Refers to the [official prject documentation](http://csv.adaltas.com/stringify/) | ||
// Refers to the [official prject documentation](http://csv.js.org/stringify/) | ||
// on how to call this function. | ||
@@ -438,16 +438,16 @@ module.exports = function() { | ||
quotedMatch = quotedMatch && quotedMatch.length > 0; | ||
shouldQuote = containsQuote || containsdelimiter || containsRowDelimiter || quoted || quotedString || quotedMatch; | ||
if (shouldQuote && containsEscape) { | ||
shouldQuote = containsQuote === true || containsdelimiter || containsRowDelimiter || quoted || quotedString || quotedMatch; | ||
if (shouldQuote === true && containsEscape === true) { | ||
regexp = escape === '\\' ? new RegExp(escape + escape, 'g') : new RegExp(escape, 'g'); | ||
value = value.replace(regexp, escape + escape); | ||
} | ||
if (containsQuote) { | ||
if (containsQuote === true) { | ||
regexp = new RegExp(quote, 'g'); | ||
value = value.replace(regexp, escape + quote); | ||
} | ||
if (shouldQuote) { | ||
if (shouldQuote === true) { | ||
value = quote + value + quote; | ||
} | ||
csvrecord += value; | ||
} else if (quoted_empty || ((quoted_empty == null) && field === '' && quoted_string)) { | ||
} else if (quoted_empty === true || ((quoted_empty == null) && field === '' && quoted_string !== false)) { | ||
csvrecord += quote + quote; | ||
@@ -454,0 +454,0 @@ } |
{ | ||
"version": "5.3.3", | ||
"version": "5.3.4", | ||
"name": "csv-stringify", | ||
@@ -16,2 +16,3 @@ "description": "CSV stringifier implementing the Node.js `stream.Transform` API", | ||
"homepage": "https://csv.js.org/stringify/", | ||
"author": "David Worms <david@adaltas.com> (https://www.adaltas.com)", | ||
"coffeelintConfig": { | ||
@@ -31,14 +32,15 @@ "indentation": { | ||
"devDependencies": { | ||
"@babel/cli": "^7.5.5", | ||
"@babel/core": "^7.5.5", | ||
"@babel/preset-env": "^7.5.5", | ||
"@babel/cli": "^7.6.0", | ||
"@babel/core": "^7.6.0", | ||
"@babel/preset-env": "^7.6.0", | ||
"@types/mocha": "^5.2.7", | ||
"@types/node": "^12.6.9", | ||
"@types/node": "^12.7.5", | ||
"@types/should": "^13.0.0", | ||
"coffeescript": "~2.4.1", | ||
"csv-generate": "~3.2.3", | ||
"each": "^1.2.1", | ||
"mocha": "~6.2.0", | ||
"should": "~13.2.3", | ||
"ts-node": "^8.3.0", | ||
"typescript": "^3.5.3" | ||
"ts-node": "^8.4.1", | ||
"typescript": "^3.6.3" | ||
}, | ||
@@ -45,0 +47,0 @@ "files": [ |
@@ -51,3 +51,3 @@ | ||
To generate the JavaScript files, run `npm run coffee`. | ||
To generate the JavaScript files, run `npm run build`. | ||
@@ -66,3 +66,3 @@ The test suite is run online with | ||
[stream_transform]: http://nodejs.org/api/stream.html#stream_class_stream_transform | ||
[examples]: http://csv.adaltas.com/stringify/examples/ | ||
[examples]: http://csv.js.org/stringify/examples/ | ||
[csv]: https://github.com/adaltas/node-csv |
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
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
68776
1
13