lib/DB.js
function DB() {
  this.requests = {}
  process.on('message', function(message) {
    if (message.type !== 'cache:response') {
      return
    }

    /** @type {{error: Error, response: string, uid: string, method: string}} */
    var data = message.data
    // The requests for this UID may not exist because there can be multiple
    // instances of Impromptu.
    if (!(this.requests[data.method] && this.requests[data.method][data.uid])) {
      return
    }

    var callbacks = this.requests[data.method][data.uid]
    for (var i = 0; i < callbacks.length; i++) {
      var callback = callbacks[i]
      callback(data.error, data.response)
    }

    delete this.requests[data.method][data.uid]
  }.bind(this))
}
function DB() {
  this.requests = {}
  process.on('message', function(message) {
    if (message.type !== 'cache:response') {
      return
    }

    /** @type {{error: Error, response: string, uid: string, method: string}} */
    var data = message.data
    // The requests for this UID may not exist because there can be multiple
    // instances of Impromptu.
    if (!(this.requests[data.method] && this.requests[data.method][data.uid])) {
      return
    }

    var callbacks = this.requests[data.method][data.uid]
    for (var i = 0; i < callbacks.length; i++) {
      var callback = callbacks[i]
      callback(data.error, data.response)
    }

    delete this.requests[data.method][data.uid]
  }.bind(this))
}
function DB ( ) { this . requests = { } process . on ( 'message' , function ( message ) { if ( message . type !== 'cache:response' ) { return } /** @type {{error: Error, response: string, uid: string, method: string}} */ var data = message . data // The requests for this UID may not exist because there can be multiple // instances of Impromptu. if ( ! ( this . requests [ data . method ] && this . requests [ data . method ] [ data . uid ] ) ) { return } var callbacks = this . requests [ data . method ] [ data . uid ] for ( var i = 0 ; i < callbacks . length ; i ++ ) { var callback = callbacks [ i ] callback ( data . error , data . response ) } delete this . requests [ data . method ] [ data . uid ] } . bind ( this ) ) }
The Impromptu database client.
@constructor
The Impromptu database client .