Skip to content

Commit

Permalink
(#201) - use default exports instead of named exports
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanlawson committed Jul 13, 2016
1 parent ac3b938 commit bbeadf0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ var utils = require('./utils');
var httpIndexes = require('./adapters/http');
var localIndexes = require('./adapters/local');

exports.createIndex = utils.toPromise(function (requestDef, callback) {
var plugin = {};
plugin.createIndex = utils.toPromise(function (requestDef, callback) {

if (typeof requestDef !== 'object') {
return callback(new Error('you must provide an index to create'));
Expand All @@ -16,7 +17,7 @@ exports.createIndex = utils.toPromise(function (requestDef, callback) {
adapter.createIndex(this, requestDef, callback);
});

exports.find = utils.toPromise(function (requestDef, callback) {
plugin.find = utils.toPromise(function (requestDef, callback) {

if (typeof callback === 'undefined') {
callback = requestDef;
Expand All @@ -32,14 +33,14 @@ exports.find = utils.toPromise(function (requestDef, callback) {
adapter.find(this, requestDef, callback);
});

exports.getIndexes = utils.toPromise(function (callback) {
plugin.getIndexes = utils.toPromise(function (callback) {

var adapter = this.type() === 'http' ? httpIndexes : localIndexes;

adapter.getIndexes(this, callback);
});

exports.deleteIndex = utils.toPromise(function (indexDef, callback) {
plugin.deleteIndex = utils.toPromise(function (indexDef, callback) {

if (typeof indexDef !== 'object') {
return callback(new Error('you must provide an index to delete'));
Expand All @@ -50,7 +51,9 @@ exports.deleteIndex = utils.toPromise(function (indexDef, callback) {
adapter.deleteIndex(this, indexDef, callback);
});

module.exports = plugin;

/* istanbul ignore next */
if (typeof window !== 'undefined' && window.PouchDB) {
window.PouchDB.plugin(exports);
window.PouchDB.plugin(plugin);
}

0 comments on commit bbeadf0

Please sign in to comment.