diff options
Diffstat (limited to 'deps/npm/node_modules/ini/ini.js')
-rw-r--r-- | deps/npm/node_modules/ini/ini.js | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/deps/npm/node_modules/ini/ini.js b/deps/npm/node_modules/ini/ini.js index f5e4441186..1e232e7438 100644 --- a/deps/npm/node_modules/ini/ini.js +++ b/deps/npm/node_modules/ini/ini.js @@ -7,31 +7,47 @@ exports.unsafe = unsafe var eol = process.platform === "win32" ? "\r\n" : "\n" -function encode (obj, section) { +function encode (obj, opt) { var children = [] , out = "" + if (typeof opt === "string") { + opt = { + section: opt, + whitespace: false + } + } else { + opt = opt || {} + opt.whitespace = opt.whitespace === true + } + + var separator = opt.whitespace ? " = " : "=" + Object.keys(obj).forEach(function (k, _, __) { var val = obj[k] if (val && Array.isArray(val)) { val.forEach(function(item) { - out += safe(k + "[]") + "=" + safe(item) + "\n" + out += safe(k + "[]") + separator + safe(item) + "\n" }) } else if (val && typeof val === "object") { children.push(k) } else { - out += safe(k) + "=" + safe(val) + eol + out += safe(k) + separator + safe(val) + eol } }) - if (section && out.length) { - out = "[" + safe(section) + "]" + eol + out + if (opt.section && out.length) { + out = "[" + safe(opt.section) + "]" + eol + out } children.forEach(function (k, _, __) { var nk = dotSplit(k).join('\\.') - var child = encode(obj[k], (section ? section + "." : "") + nk) + var section = (opt.section ? opt.section + "." : "") + nk + var child = encode(obj[k], { + section: section, + whitespace: opt.whitespace + }) if (out.length && child.length) { out += eol } |