From 93d717e2edb2de0cd383ab7f5cca481258373f39 Mon Sep 17 00:00:00 2001 From: EV Date: Sun, 23 Jun 2019 12:42:46 +0200 Subject: [PATCH 1/3] solve #86 --- lib/pouch-utils.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pouch-utils.js b/lib/pouch-utils.js index 021b8cb..cc0da87 100644 --- a/lib/pouch-utils.js +++ b/lib/pouch-utils.js @@ -1,6 +1,7 @@ 'use strict'; -var Promise = require('pouchdb-promise'); +function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } +var Promise = typeof Promise === 'function' ? Promise : _interopDefault(require('pouchdb-promise')); /* istanbul ignore next */ exports.once = function (fun) { var called = false; From 15c58829e36d88a5328db0344f01bfffa22b1a23 Mon Sep 17 00:00:00 2001 From: EV Date: Sun, 23 Jun 2019 12:49:24 +0200 Subject: [PATCH 2/3] formating to pass linter --- lib/pouch-utils.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/pouch-utils.js b/lib/pouch-utils.js index cc0da87..75d4d6a 100644 --- a/lib/pouch-utils.js +++ b/lib/pouch-utils.js @@ -1,6 +1,12 @@ 'use strict'; -function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } +function _interopDefault (ex) { + if(ex && (typeof ex === 'object') && 'default' in ex) { + return ex['default']; + } + return ex; +} + var Promise = typeof Promise === 'function' ? Promise : _interopDefault(require('pouchdb-promise')); /* istanbul ignore next */ exports.once = function (fun) { From 852b8e566ae774440b2f8ec1d806af48143cfbcf Mon Sep 17 00:00:00 2001 From: EV Date: Sun, 23 Jun 2019 13:24:07 +0200 Subject: [PATCH 3/3] istanbul annotations & refactor --- lib/pouch-utils.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/pouch-utils.js b/lib/pouch-utils.js index 75d4d6a..c14a27e 100644 --- a/lib/pouch-utils.js +++ b/lib/pouch-utils.js @@ -1,5 +1,6 @@ 'use strict'; +/* istanbul ignore next */ function _interopDefault (ex) { if(ex && (typeof ex === 'object') && 'default' in ex) { return ex['default']; @@ -7,7 +8,16 @@ function _interopDefault (ex) { return ex; } -var Promise = typeof Promise === 'function' ? Promise : _interopDefault(require('pouchdb-promise')); +/* istanbul ignore next */ +function _getPromise() { + if(typeof Promise === 'function') { + return Promise; + } + return _interopDefault(require('pouchdb-promise')); +} + +var Promise = _getPromise(); + /* istanbul ignore next */ exports.once = function (fun) { var called = false;