Skip to content

Commit

Permalink
refactor: move methods to lib/*
Browse files Browse the repository at this point in the history
BREAKING CHANGE:

separate methods like `require(pouchdb-hoodie-api)` can no longer be required directly
  • Loading branch information
gr2m committed Mar 4, 2017
1 parent 87a2e4b commit cc53124
Show file tree
Hide file tree
Showing 36 changed files with 23 additions and 23 deletions.
24 changes: 12 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var exports = module.exports = { hoodieApi: hoodieApi }

var EventEmitter = require('events').EventEmitter
var startListenToChanges = require('./helpers/start-listen-to-changes')
var startListenToChanges = require('./lib/helpers/start-listen-to-changes')

function hoodieApi (options) {
var state = {
Expand All @@ -14,20 +14,20 @@ function hoodieApi (options) {

return {
db: this,
add: require('./add').bind(this, null),
find: require('./find').bind(this, null),
findAll: require('./find-all').bind(this, null),
findOrAdd: require('./find-or-add').bind(this, state, null),
update: require('./update').bind(this, null),
updateOrAdd: require('./update-or-add').bind(this, null),
updateAll: require('./update-all').bind(this, null),
remove: require('./remove').bind(this, null),
removeAll: require('./remove-all').bind(this, null),
withIdPrefix: require('./with-id-prefix').bind(this, state),
add: require('./lib/add').bind(this, null),
find: require('./lib/find').bind(this, null),
findAll: require('./lib/find-all').bind(this, null),
findOrAdd: require('./lib/find-or-add').bind(this, state, null),
update: require('./lib/update').bind(this, null),
updateOrAdd: require('./lib/update-or-add').bind(this, null),
updateAll: require('./lib/update-all').bind(this, null),
remove: require('./lib/remove').bind(this, null),
removeAll: require('./lib/remove-all').bind(this, null),
withIdPrefix: require('./lib/with-id-prefix').bind(this, state),
on: require('./lib/on').bind(this, state),
one: require('./lib/one').bind(this, state),
off: require('./lib/off').bind(this, state),
clear: require('./clear').bind(this, state)
clear: require('./lib/clear').bind(this, state)
}
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions with-id-prefix.js → lib/with-id-prefix.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ function withIdPrefix (state, prefix) {
withIdPrefix: function (moarPrefix) {
return withIdPrefix.call(db, state, prefix + moarPrefix)
},
on: require('./lib/on').bind(this, {emitter: emitter}),
one: require('./lib/one').bind(this, {emitter: emitter}),
off: require('./lib/off').bind(this, {emitter: emitter})
on: require('./on').bind(this, {emitter: emitter}),
one: require('./one').bind(this, {emitter: emitter}),
off: require('./off').bind(this, {emitter: emitter})
}

state.emitter.on('change', function (eventName, object) {
Expand Down
4 changes: 2 additions & 2 deletions tests/specs/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ test('store.add(object) makes createdAt and updatedAt timestamps', function (t)
var db = dbFactory()
var store = db.hoodieApi()

var now = require('../../utils/now')
var now = require('../../lib/utils/now')
var isValidDate = require('../utils/is-valid-date')

store.add({
Expand All @@ -183,7 +183,7 @@ test('store.add([objects]) makes createdAt and updatedAt timestamps', function (
var db = dbFactory()
var store = db.hoodieApi()

var now = require('../../utils/now')
var now = require('../../lib/utils/now')
var isValidDate = require('../utils/is-valid-date')

store.add([{
Expand Down
2 changes: 1 addition & 1 deletion tests/specs/remove-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ test('store.removeAll([objects]) creates deletedAt timestamps', function (t) {
var db = dbFactory()
var store = db.hoodieApi()

var now = require('../../utils/now')
var now = require('../../lib/utils/now')
var isValidDate = require('../utils/is-valid-date')

store.add([{
Expand Down
4 changes: 2 additions & 2 deletions tests/specs/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ test('store.remove(object) creates deletedAt timestamp', function (t) {
var db = dbFactory()
var store = db.hoodieApi()

var now = require('../../utils/now')
var now = require('../../lib/utils/now')
var isValidDate = require('../utils/is-valid-date')

store.add({
Expand All @@ -290,7 +290,7 @@ test('store.remove([objects]) creates deletedAt timestamps', function (t) {
var db = dbFactory()
var store = db.hoodieApi()

var now = require('../../utils/now')
var now = require('../../lib/utils/now')
var isValidDate = require('../utils/is-valid-date')

store.add([{
Expand Down
2 changes: 1 addition & 1 deletion tests/specs/update-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ test('store.updateAll([objects]) updates all updatedAt timestamps', function (t)
var db = dbFactory()
var store = db.hoodieApi()

var now = require('../../utils/now')
var now = require('../../lib/utils/now')
var isValidDate = require('../utils/is-valid-date')

var updatedCount = 0
Expand Down
4 changes: 2 additions & 2 deletions tests/specs/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ test('store.update(object) updates updatedAt timestamp', function (t) {
var db = dbFactory()
var store = db.hoodieApi()

var now = require('../../utils/now')
var now = require('../../lib/utils/now')
var isValidDate = require('../utils/is-valid-date')

store.add({
Expand Down Expand Up @@ -351,7 +351,7 @@ test('store.update([objects]) updates updatedAt timestamps', function (t) {
var db = dbFactory()
var store = db.hoodieApi()

var now = require('../../utils/now')
var now = require('../../lib/utils/now')
var isValidDate = require('../utils/is-valid-date')

var updatedCount = 0
Expand Down

0 comments on commit cc53124

Please sign in to comment.