log.js
function Log (opts) {
  if (!opts) opts = { }

  if (typeof opts.nodeId === 'undefined') {
    throw new Error('Expected node ID')
  }
  if (typeof opts.store !== 'object') {
    throw new Error('Expected store')
  }
  if (opts.nodeId.indexOf(' ') !== -1) {
    throw new Error('Space is prohibited in node ID')
  }

  /**
   * Unique node ID. It is used in action IDs.
   * @type {string|number}
   */
  this.nodeId = opts.nodeId

  this.lastTime = 0
  this.sequence = 0

  this.store = opts.store

  this.emitter = new NanoEvents()
}
function Log (opts) {
  if (!opts) opts = { }

  if (typeof opts.nodeId === 'undefined') {
    throw new Error('Expected node ID')
  }
  if (typeof opts.store !== 'object') {
    throw new Error('Expected store')
  }
  if (opts.nodeId.indexOf(' ') !== -1) {
    throw new Error('Space is prohibited in node ID')
  }

  /**
   * Unique node ID. It is used in action IDs.
   * @type {string|number}
   */
  this.nodeId = opts.nodeId

  this.lastTime = 0
  this.sequence = 0

  this.store = opts.store

  this.emitter = new NanoEvents()
}
function Log ( opts ) { if ( ! opts ) opts = { } if ( typeof opts . nodeId === 'undefined' ) { throw new Error ( 'Expected node ID' ) } if ( typeof opts . store !== 'object' ) { throw new Error ( 'Expected store' ) } if ( opts . nodeId . indexOf ( ' ' ) !== - 1 ) { throw new Error ( 'Space is prohibited in node ID' ) } /**
   * Unique node ID. It is used in action IDs.
   * @type {string|number}
   */ this . nodeId = opts . nodeId this . lastTime = 0 this . sequence = 0 this . store = opts . store this . emitter = new NanoEvents ( ) }
Stores actions with time marks. Log is main idea in Logux.
In most end-user tools you will work with log and should know log API.

@param {object} opts Options.
@param {Store} opts.store Store for log.
@param {string|number} opts.nodeId Unique current machine name.

@example
import Log from 'logux-core/log'
const log = new Log({
store: new MemoryStore(),
nodeId: 'client:134'
})

log.on('add', beeper)
log.add({ type: 'beep' })

@class
Stores actions with time marks . Log is main idea in Logux . In most end - user tools you will work with log and should know log API .