Skip to content

Commit

Permalink
refactoring formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly-t committed Sep 30, 2020
1 parent fc11c4f commit 769f8a0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/formatting.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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);
Expand All @@ -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});
Expand Down Expand Up @@ -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});
}

//////////////////////////////////////////////////////
Expand Down

0 comments on commit 769f8a0

Please sign in to comment.