import mitt from 'mitt'

function warn (msg) {
  (console.error || console.log)(msg)
}

export function createStore (initialState) {
  let state = initialState
  let events = mitt()

  return {
    emit: events.emit,
    on: events.on,
    off: events.off,
    addReducer (reducer) {
      for (let type in reducer) {
        if (reducer.hasOwnProperty(type)) {
          events.on(type, (e) => {
            let result = reducer[type](this.state, e)
            if (!result) {
              warn('You forgot to return something from your reducer! Check: "' +
                type +
                '" on reducer with keys: ' +
                Object.keys(reducer))
            }
            this.state = result
          })
        }
      }
    },
    get state () { return state },
    set state (nextState) { state = nextState }
  }
}

@@ -490,17 +490,17 @@
    warn(
-'
+%60
 You forg
@@ -553,52 +553,15 @@
 k: %22
-' +%0A                type +%0A                '
+$%7Btype%7D
 %22 on
@@ -584,28 +584,10 @@
 ys: 
-' +%0A                
+$%7B
 Obje
@@ -602,17 +602,20 @@
 reducer)
-)
+%7D%60);
 %0A       

use template strings