All files create.js

100% Statements 7/7
100% Branches 3/3
100% Functions 2/2
100% Lines 7/7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28            1x 12x             1x 16x 4x               12x 12x    
import { argumentError, isValid } from './utils'
import { post } from './post'
import { postAll } from './postAll'
import { register } from './register'
import { unregister } from './unregister'
 
const options = actions => {
  return {
    expected: 'an array of objects',
    received: actions,
    extraInfo: 'Every action should be an object containing two fields:\n* message\n* func'
  }
}
 
export const create = (actions = []) => {
  if (isValid(actions)('actionsArray')) {
    return {
      actions: actions,
      postMessage: post(actions),
      postAll: postAll,
      register: register(actions),
      unregister: unregister(actions)
    }
  }
  console.error(argumentError(options(actions)))
  return null
}