'use strict';

var log = require('../util/log.js');

// Implementation of exported APIs. For example registerMap, getMap.
// The implementations will be registered when installing the component.
// Avoid these code being bundled to the core module.
var implsStore = {};
// TODO Type
function registerImpl(name, impl) {
  if (process.env.NODE_ENV !== 'production') {
    if (implsStore[name]) {
      log.error("Already has an implementation of " + name + ".");
    }
  }
  implsStore[name] = impl;
}
function getImpl(name) {
  if (process.env.NODE_ENV !== 'production') {
    if (!implsStore[name]) {
      log.error("Implementation of " + name + " doesn't exists.");
    }
  }
  return implsStore[name];
}

exports.getImpl = getImpl;
exports.registerImpl = registerImpl;
