couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From glynnb...@apache.org
Subject [couchdb-nano] 05/05: new linting standards applied for nano.js
Date Thu, 02 May 2019 14:40:21 GMT
This is an automated email from the ASF dual-hosted git repository.

glynnbird pushed a commit to branch prepare8.1.0
in repository https://gitbox.apache.org/repos/asf/couchdb-nano.git

commit 06e7896e5776cc2c33ada7200af1e1228c00cf34
Author: Glynn Bird <glynn.bird@gmail.com>
AuthorDate: Thu May 2 15:35:41 2019 +0100

    new linting standards applied for nano.js
---
 lib/nano.js | 118 ++++++++++++++++++++++++++++++------------------------------
 1 file changed, 59 insertions(+), 59 deletions(-)

diff --git a/lib/nano.js b/lib/nano.js
index 1d5801b..8522a30 100644
--- a/lib/nano.js
+++ b/lib/nano.js
@@ -40,10 +40,10 @@ module.exports = exports = function dbScope (cfg) {
   let serverScope = {}
 
   if (typeof cfg === 'string') {
-    cfg = {url: cfg}
+    cfg = { url: cfg }
   }
 
-  assert.equal(typeof cfg, 'object',
+  assert.strictEqual(typeof cfg, 'object',
     'You must specify the endpoint url when invoking this module')
   assert.ok(/^https?:/.test(cfg.url), 'url is not valid')
 
@@ -88,7 +88,7 @@ module.exports = exports = function dbScope (cfg) {
         statusCode: response.statusCode
       }, response.headers)
       if (err) {
-        log({err: 'socket', body: body, headers: responseHeaders})
+        log({ err: 'socket', body: body, headers: responseHeaders })
         const returnError = errs.merge(err, {
           message: 'error happened in your connection',
           scope: 'socket',
@@ -113,7 +113,7 @@ module.exports = exports = function dbScope (cfg) {
       }
 
       if (responseHeaders.statusCode >= 200 && responseHeaders.statusCode <
400) {
-        log({err: null, body: parsed, headers: responseHeaders})
+        log({ err: null, body: parsed, headers: responseHeaders })
         if (resolve) {
           resolve(parsed)
         }
@@ -123,11 +123,11 @@ module.exports = exports = function dbScope (cfg) {
         return
       }
 
-      log({err: 'couch', body: parsed, headers: responseHeaders})
+      log({ err: 'couch', body: parsed, headers: responseHeaders })
 
       // cloudant stacktrace
       if (typeof parsed === 'string') {
-        parsed = {message: parsed}
+        parsed = { message: parsed }
       }
 
       if (!parsed.message && (parsed.reason || parsed.error)) {
@@ -165,15 +165,15 @@ module.exports = exports = function dbScope (cfg) {
   function relax (opts, callback) {
     if (typeof opts === 'function') {
       callback = opts
-      opts = {path: ''}
+      opts = { path: '' }
     }
 
     if (typeof opts === 'string') {
-      opts = {path: opts}
+      opts = { path: opts }
     }
 
     if (!opts) {
-      opts = {path: ''}
+      opts = { path: '' }
       callback = null
     }
 
@@ -314,12 +314,12 @@ module.exports = exports = function dbScope (cfg) {
 
   // http://docs.couchdb.org/en/latest/api/server/authn.html#post--_session
   function session (callback) {
-    return relax({db: '_session'}, callback)
+    return relax({ db: '_session' }, callback)
   }
 
   // http://docs.couchdb.org/en/latest/api/server/common.html#get--_db_updates
   function updates (qs0, callback0) {
-    const {opts, callback} = getCallback(qs0, callback0)
+    const { opts, callback } = getCallback(qs0, callback0)
     return relax({
       db: '_db_updates',
       qs: opts
@@ -332,28 +332,28 @@ module.exports = exports = function dbScope (cfg) {
 
   // http://docs.couchdb.org/en/latest/api/database/common.html#put--db
   function createDb (dbName, qs0, callback0) {
-    const {opts, callback} = getCallback(qs0, callback0)
-    return relax({db: dbName, method: 'PUT', qs: opts}, callback)
+    const { opts, callback } = getCallback(qs0, callback0)
+    return relax({ db: dbName, method: 'PUT', qs: opts }, callback)
   }
 
   // http://docs.couchdb.org/en/latest/api/database/common.html#delete--db
   function destroyDb (dbName, callback) {
-    return relax({db: dbName, method: 'DELETE'}, callback)
+    return relax({ db: dbName, method: 'DELETE' }, callback)
   }
 
   // http://docs.couchdb.org/en/latest/api/database/common.html#get--db
   function getDb (dbName, callback) {
-    return relax({db: dbName}, callback)
+    return relax({ db: dbName }, callback)
   }
 
   // http://docs.couchdb.org/en/latest/api/server/common.html#get--_all_dbs
   function listDbs (callback) {
-    return relax({db: '_all_dbs'}, callback)
+    return relax({ db: '_all_dbs' }, callback)
   }
 
   // http://docs.couchdb.org/en/latest/api/server/common.html#get--_all_dbs
   function listDbsAsStream () {
-    return relax({db: '_all_dbs', stream: true})
+    return relax({ db: '_all_dbs', stream: true })
   }
 
   // http://docs.couchdb.org/en/latest/api/database/compact.html#post--db-_compact
@@ -372,16 +372,16 @@ module.exports = exports = function dbScope (cfg) {
 
   // http://docs.couchdb.org/en/latest/api/database/changes.html#get--db-_changes
   function changesDb (dbName, qs0, callback0) {
-    const {opts, callback} = getCallback(qs0, callback0)
-    return relax({db: dbName, path: '_changes', qs: opts}, callback)
+    const { opts, callback } = getCallback(qs0, callback0)
+    return relax({ db: dbName, path: '_changes', qs: opts }, callback)
   }
 
   function changesDbAsStream (dbName, opts) {
-    return relax({db: dbName, path: '_changes', stream: true, qs: opts})
+    return relax({ db: dbName, path: '_changes', stream: true, qs: opts })
   }
 
   function followDb (dbName, qs0, callback0) {
-    const {opts, callback} = getCallback(qs0, callback0)
+    const { opts, callback } = getCallback(qs0, callback0)
     opts.db = urlResolveFix(cfg.url, encodeURIComponent(dbName))
     opts.httpAgent = httpAgent
     if (typeof callback === 'function') {
@@ -406,13 +406,13 @@ module.exports = exports = function dbScope (cfg) {
 
   // http://docs.couchdb.org/en/latest/api/server/common.html#post--_replicate
   function replicateDb (source, target, opts0, callback0) {
-    const {opts, callback} = getCallback(opts0, callback0)
+    const { opts, callback } = getCallback(opts0, callback0)
 
     // _replicate
     opts.source = _serializeAsUrl(source)
     opts.target = _serializeAsUrl(target)
 
-    return relax({db: '_replicate', body: opts, method: 'POST'}, callback)
+    return relax({ db: '_replicate', body: opts, method: 'POST' }, callback)
   }
 
   // http://docs.couchdb.org/en/latest/api/server/common.html#uuids
@@ -421,34 +421,34 @@ module.exports = exports = function dbScope (cfg) {
       callback = count
       count = 1
     }
-    return relax({method: 'GET', path: '_uuids', qs: {count: count}}, callback)
+    return relax({ method: 'GET', path: '_uuids', qs: { count: count } }, callback)
   }
 
   // http://guide.couchdb.org/draft/replication.html
   function enableReplication (source, target, opts0, callback0) {
-    const {opts, callback} = getCallback(opts0, callback0)
+    const { opts, callback } = getCallback(opts0, callback0)
 
     // _replicator
     opts.source = _serializeAsUrl(source)
     opts.target = _serializeAsUrl(target)
 
-    return relax({db: '_replicator', body: opts, method: 'POST'}, callback)
+    return relax({ db: '_replicator', body: opts, method: 'POST' }, callback)
   }
 
   // http://guide.couchdb.org/draft/replication.html
   function queryReplication (id, opts0, callback0) {
-    const {opts, callback} = getCallback(opts0, callback0)
-    return relax({db: '_replicator', method: 'GET', path: id, qs: opts}, callback)
+    const { opts, callback } = getCallback(opts0, callback0)
+    return relax({ db: '_replicator', method: 'GET', path: id, qs: opts }, callback)
   }
 
   // http://guide.couchdb.org/draft/replication.html
   function disableReplication (id, rev, opts0, callback0) {
-    const {opts, callback} = getCallback(opts0, callback0)
+    const { opts, callback } = getCallback(opts0, callback0)
     const req = {
       db: '_replicator',
       method: 'DELETE',
       path: id,
-      qs: Object.assign(opts, {rev: rev})
+      qs: Object.assign(opts, { rev: rev })
     }
     return relax(req, callback)
   }
@@ -460,12 +460,12 @@ module.exports = exports = function dbScope (cfg) {
     // http://docs.couchdb.org/en/latest/api/document/common.html#put--db-docid
     // http://docs.couchdb.org/en/latest/api/database/common.html#post--db
     function insertDoc (doc, qs0, callback0) {
-      const req = {db: dbName, body: doc, method: 'POST'}
+      const req = { db: dbName, body: doc, method: 'POST' }
 
-      let {opts, callback} = getCallback(qs0, callback0)
+      let { opts, callback } = getCallback(qs0, callback0)
 
       if (typeof opts === 'string') {
-        opts = {docName: opts}
+        opts = { docName: opts }
       }
 
       if (opts) {
@@ -494,19 +494,19 @@ module.exports = exports = function dbScope (cfg) {
           db: dbName,
           doc: docName,
           method: 'DELETE',
-          qs: {rev: rev}
+          qs: { rev: rev }
         }, callback)
       }
     }
 
     // http://docs.couchdb.org/en/latest/api/document/common.html#get--db-docid
     function getDoc (docName, qs0, callback0) {
-      const {opts, callback} = getCallback(qs0, callback0)
+      const { opts, callback } = getCallback(qs0, callback0)
 
       if (!docName) {
         if (callback) { callback(new Error('Invalid doc id'), null) }
       } else {
-        return relax({db: dbName, doc: docName, qs: opts}, callback)
+        return relax({ db: dbName, doc: docName, qs: opts }, callback)
       }
     }
 
@@ -541,13 +541,13 @@ module.exports = exports = function dbScope (cfg) {
 
     // http://docs.couchdb.org/en/latest/api/document/common.html#copy--db-docid
     function copyDoc (docSrc, docDest, opts0, callback0) {
-      const {opts, callback} = getCallback(opts0, callback0)
+      const { opts, callback } = getCallback(opts0, callback0)
 
       const qs = {
         db: dbName,
         doc: docSrc,
         method: 'COPY',
-        headers: {'Destination': docDest}
+        headers: { 'Destination': docDest }
       }
 
       if (opts.overwrite) {
@@ -581,18 +581,18 @@ module.exports = exports = function dbScope (cfg) {
 
     // http://docs.couchdb.org/en/latest/api/database/bulk-api.html#get--db-_all_docs
     function listDoc (qs0, callback0) {
-      const {opts, callback} = getCallback(qs0, callback0)
-      return relax({db: dbName, path: '_all_docs', qs: opts}, callback)
+      const { opts, callback } = getCallback(qs0, callback0)
+      return relax({ db: dbName, path: '_all_docs', qs: opts }, callback)
     }
 
     // http://docs.couchdb.org/en/latest/api/database/bulk-api.html#get--db-_all_docs
     function listDocAsStream (opts) {
-      return relax({db: dbName, path: '_all_docs', qs: opts, stream: true})
+      return relax({ db: dbName, path: '_all_docs', qs: opts, stream: true })
     }
 
     // http://docs.couchdb.org/en/latest/api/database/bulk-api.html#post--db-_all_docs
     function fetchDocs (docNames, qs0, callback0) {
-      const {opts, callback} = getCallback(qs0, callback0)
+      const { opts, callback } = getCallback(qs0, callback0)
       opts['include_docs'] = true
 
       return relax({
@@ -605,7 +605,7 @@ module.exports = exports = function dbScope (cfg) {
     }
 
     function fetchRevs (docNames, qs0, callback0) {
-      const {opts, callback} = getCallback(qs0, callback0)
+      const { opts, callback } = getCallback(qs0, callback0)
       return relax({
         db: dbName,
         path: '_all_docs',
@@ -616,7 +616,7 @@ module.exports = exports = function dbScope (cfg) {
     }
 
     function view (ddoc, viewName, meta, qs0, callback0) {
-      const {opts, callback} = getCallback(qs0, callback0)
+      const { opts, callback } = getCallback(qs0, callback0)
 
       if (typeof meta.stream !== 'boolean') {
         meta.stream = false
@@ -637,7 +637,7 @@ module.exports = exports = function dbScope (cfg) {
           stream: meta.stream
         }, callback)
       } else if (qs1 && qs1.keys) {
-        const body = {keys: qs1.keys}
+        const body = { keys: qs1.keys }
         delete qs1.keys
         return relax({
           db: dbName,
@@ -648,7 +648,7 @@ module.exports = exports = function dbScope (cfg) {
           stream: meta.stream
         }, callback)
       } else if (qs1 && qs1.queries) {
-        const body = {queries: qs1.queries}
+        const body = { queries: qs1.queries }
         delete qs1.queries
         return relax({
           db: dbName,
@@ -676,27 +676,27 @@ module.exports = exports = function dbScope (cfg) {
 
     // http://docs.couchdb.org/en/latest/api/ddoc/views.html#post--db-_design-ddoc-_view-view
     function viewDocs (ddoc, viewName, qs, callback) {
-      return view(ddoc, viewName, {type: 'view'}, qs, callback)
+      return view(ddoc, viewName, { type: 'view' }, qs, callback)
     }
 
     // http://docs.couchdb.org/en/latest/api/ddoc/views.html#post--db-_design-ddoc-_view-view
     function viewDocsAsStream (ddoc, viewName, qs) {
-      return view(ddoc, viewName, {type: 'view', stream: true}, qs)
+      return view(ddoc, viewName, { type: 'view', stream: true }, qs)
     }
 
     // cloudant
     function viewSearch (ddoc, viewName, qs, callback) {
-      return view(ddoc, viewName, {type: 'search'}, qs, callback)
+      return view(ddoc, viewName, { type: 'search' }, qs, callback)
     }
 
     // cloudant
     function viewSearchAsStream (ddoc, viewName, qs) {
-      return view(ddoc, viewName, {type: 'search', stream: true}, qs)
+      return view(ddoc, viewName, { type: 'search', stream: true }, qs)
     }
 
     // http://docs.couchdb.org/en/latest/api/ddoc/render.html#get--db-_design-ddoc-_show-func
     function showDoc (ddoc, viewName, docName, qs, callback) {
-      return view(ddoc, viewName + '/' + docName, {type: 'show'}, qs, callback)
+      return view(ddoc, viewName + '/' + docName, { type: 'show' }, qs, callback)
     }
 
     // http://docs.couchdb.org/en/latest/api/ddoc/render.html#put--db-_design-ddoc-_update-func-docid
@@ -720,7 +720,7 @@ module.exports = exports = function dbScope (cfg) {
 
     // http://docs.couchdb.org/en/latest/api/database/bulk-api.html#post--db-_bulksDoc
     function bulksDoc (docs, qs0, callback0) {
-      const {opts, callback} = getCallback(qs0, callback0)
+      const { opts, callback } = getCallback(qs0, callback0)
       return relax({
         db: dbName,
         path: '_bulk_docs',
@@ -733,14 +733,14 @@ module.exports = exports = function dbScope (cfg) {
     // http://docs.couchdb.org/en/latest/api/document/common.html#creating-multiple-attachments
     function insertMultipart (doc, attachments, qs, callback) {
       if (typeof qs === 'string') {
-        qs = {docName: qs}
+        qs = { docName: qs }
       }
       qs = qs || {}
 
       const docName = qs.docName
       delete qs.docName
 
-      doc = Object.assign({_attachments: {}}, doc)
+      doc = Object.assign({ _attachments: {} }, doc)
 
       const multipart = []
 
@@ -752,7 +752,7 @@ module.exports = exports = function dbScope (cfg) {
           /* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */
           'content_type': att.content_type
         }
-        multipart.push({body: att.data})
+        multipart.push({ body: att.data })
       })
 
       multipart.unshift({
@@ -771,7 +771,7 @@ module.exports = exports = function dbScope (cfg) {
     }
 
     function getMultipart (docName, qs0, callback0) {
-      const {opts, callback} = getCallback(qs0, callback0)
+      const { opts, callback } = getCallback(qs0, callback0)
       opts.attachments = true
 
       return relax({
@@ -784,7 +784,7 @@ module.exports = exports = function dbScope (cfg) {
     }
 
     function insertAtt (docName, attName, att, contentType, qs0, callback0) {
-      const {opts, callback} = getCallback(qs0, callback0)
+      const { opts, callback } = getCallback(qs0, callback0)
       return relax({
         db: dbName,
         att: attName,
@@ -812,7 +812,7 @@ module.exports = exports = function dbScope (cfg) {
     }
 
     function getAtt (docName, attName, qs0, callback0) {
-      const {opts, callback} = getCallback(qs0, callback0)
+      const { opts, callback } = getCallback(qs0, callback0)
       return relax({
         db: dbName,
         att: attName,
@@ -905,7 +905,7 @@ module.exports = exports = function dbScope (cfg) {
       listAsStream: listDocAsStream,
       fetch: fetchDocs,
       fetchRevs: fetchRevs,
-      config: {url: cfg.url, db: dbName},
+      config: { url: cfg.url, db: dbName },
       multipart: {
         insert: insertMultipart,
         get: getMultipart


Mime
View raw message