Comparing version 3.1.0 to 3.1.1
@@ -72,22 +72,11 @@ const breq = require('bluereq') | ||
const cache = {} | ||
module.exports = function (opts) { | ||
const jsonRequest = JsonRequest(configParser(opts)) | ||
return function (dbName, designDocName) { | ||
const hasSpecificDesignDoc = typeof designDocName === 'string' | ||
let key = dbName | ||
if (hasSpecificDesignDoc) key += `:${designDocName}` | ||
const cachedAPI = cache[key] | ||
if (cachedAPI) { | ||
return cachedAPI | ||
} else { | ||
const API = dbHandle(jsonRequest, dbName) | ||
if (hasSpecificDesignDoc) addViewFunctions(API, designDocName) | ||
cache[key] = API | ||
return API | ||
const API = dbHandle(jsonRequest, dbName) | ||
if (typeof designDocName === 'string') { | ||
addViewFunctions(API, designDocName) | ||
} | ||
return API | ||
} | ||
} |
@@ -18,3 +18,3 @@ { | ||
}, | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"main": "lib/cot.js", | ||
@@ -21,0 +21,0 @@ "dependencies": { |
@@ -1,2 +0,2 @@ | ||
const should = require('should') | ||
require('should') | ||
const cot = require('../lib/cot') | ||
@@ -23,15 +23,2 @@ | ||
}) | ||
it('should cache db objects with identic arguments', function () { | ||
const db = cot({ port: 80, hostname: 'foo' })('bar') | ||
const db2 = cot({ port: 80, hostname: 'foo' })('bar') | ||
const db3 = cot({ port: 80, hostname: 'foo' })('bar', 'buzz') | ||
const db4 = cot({ port: 80, hostname: 'foo' })('bar', 'boudu') | ||
const db5 = cot({ port: 80, hostname: 'foo' })('bar', 'boudu') | ||
should(db === db2).be.true() | ||
should(db !== db3).be.true() | ||
should(db !== db4).be.true() | ||
should(db3 !== db4).be.true() | ||
should(db4 === db5).be.true() | ||
}) | ||
}) | ||
@@ -38,0 +25,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
67172
709