Option quoted_match

Quote all fields matching a regular expression.

Note, several options are available to control when to quote fields under certain conditions. Make sure to review the alternatives.

Example with a string

In the quotedmatchstring example, fields containing the string "." are quoted.

const stringify = require('../lib')
const assert = require('assert')

stringify([
  ['a value', '.', 'value.with.dot'],
], {
  quoted_match: '.'
}, function(err, records){
  assert.equal(records, 'a value,".","value.with.dot"\n')
})

Example with a regular expression

In the quotedmatchregexp example, fields matching the regular expression /\./ are quoted.

const stringify = require('../lib')
const assert = require('assert')

stringify([
  ['a value', '.', 'value.with.dot'],
], {
  quoted_match: /\./
}, function(err, records){
  assert.equal(records, 'a value,".","value.with.dot"\n')
})