From 769f8a0df042bb35fff4c56d393ea838b50055ad Mon Sep 17 00:00:00 2001 From: Vitaly Tomilov Date: Wed, 30 Sep 2020 20:15:45 +0100 Subject: [PATCH] refactoring formatting --- lib/formatting.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/formatting.js b/lib/formatting.js index 4603bbea..50518d43 100644 --- a/lib/formatting.js +++ b/lib/formatting.js @@ -141,7 +141,7 @@ function formatCSV(values, options) { // Query formatting helpers; const formatAs = { - object(query, obj, raw, options) { + object({query, obj, raw, options}) { options = options && typeof options === `object` ? options : {}; return query.replace(npm.patterns.namedParameters, name => { const v = formatAs.stripName(name.replace(/^\$[{(<[/]|[\s})>\]/]/g, ``), raw), @@ -167,7 +167,7 @@ const formatAs = { }); }, - array(query, array, raw, options) { + array({query, array, raw, options}) { options = options && typeof options === `object` ? options : {}; return query.replace(npm.patterns.multipleValues, name => { const v = formatAs.stripName(name.substr(1), raw); @@ -189,7 +189,7 @@ const formatAs = { }); }, - value(query, value, raw, options) { + value({query, value, raw, options}) { return query.replace(npm.patterns.singleValue, name => { const v = formatAs.stripName(name, raw); return formatValue({value, fm: v.fm, options}); @@ -293,15 +293,15 @@ function formatQuery(query, values, raw, options) { if (typeof values === `object` && values !== null) { if (values instanceof Array) { // $1, $2,... formatting to be applied; - return formatAs.array(query, values, raw, options); + return formatAs.array({query, array: values, raw, options}); } if (!(values instanceof Date || values instanceof Buffer)) { // $*propName* formatting to be applied; - return formatAs.object(query, values, raw, options); + return formatAs.object({query, obj: values, raw, options}); } } // $1 formatting to be applied, if values != undefined; - return values === undefined ? query : formatAs.value(query, values, raw, options); + return values === undefined ? query : formatAs.value({query, value: values, raw, options}); } //////////////////////////////////////////////////////