@missive/ndex
Version:
Ndex is an indexedDB wrapper
33 lines (26 loc) • 921 B
text/coffeescript
class Adapter
constructor: () ->
this.proxyAPIMethods()
# Sync
proxyAPIMethods: (objectStoreNames = []) ->
methods = (k for k, v of when typeof v is 'function')
methods.forEach (method) =>
return if method is 'index'
this[method] = => this.handleMethod(method, arguments...)
index: (objectStoreName, indexName) ->
.createNamespaceForIndex(indexName, objectStoreName, this)
handleLog: (args) ->
return unless
return if isnt console
{ type, data } = args
switch type
when 'transaction.start'
console.groupCollapsed(data)
when 'request'
console.log(data)
when 'transaction.end'
console.groupEnd()
# Async
proxyObjectStoresNamespace: (objectStoreNames) ->
.createNamespaceForObjectStores(objectStoreNames, this)
module.exports = Adapter