How to use the fxjs.reduce function in fxjs

To help you get started, we’ve selected a few fxjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github marpple / FxSQL / src / index.js View on Github external
function merge_query(queries, sep = ' ') {
    if (queries.find(is_injection)) return SymbolInjection;
    var query = reduce((res, query) => {
      if (!query) return res;
      if (query.text) res.text += (sep + query.text);
      if (query.values) res.values.push(...query.values);
      return res;
    }, {
      text: '',
      values: []
    }, queries);
    query.text = query.text.replace(/\n/g, ' ').replace(/\s\s*/g, ' ').trim();
    return query;
  }