UNPKG

@warp-works/warpjs-utils

Version:

Utility functions for WarpJS and plugins

39 lines (29 loc) 1.12 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _baseComponentName = require('./base-component-name'); var _baseComponentName2 = _interopRequireDefault(_baseComponentName); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.default = function (state, packageName, Component, id) { if (!packageName) { throw new Error('Missing \'packageName\'.'); } else if (!state[packageName]) { state[packageName] = {}; } if (!Component) { throw new Error('Missing \'Component\'.'); } var componentName = (0, _baseComponentName2.default)(Component.displayName); if (!componentName) { throw new Error('Missing \'Component.displayName\'.'); } else if (!state[packageName][componentName]) { state[packageName][componentName] = {}; } if (!id) { throw new Error('Missing \'id\'.'); } else if (!state[packageName][componentName][id]) { state[packageName][componentName][id] = {}; } return state[packageName][componentName][id]; };