UNPKG

react-magnetic-di

Version:
38 lines (30 loc) 972 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.warnOnce = warnOnce; exports.getDisplayName = getDisplayName; exports.injectable = injectable; exports.mock = void 0; var _constants = require("./constants"); var hasWarned = false; function warnOnce(message) { if (!hasWarned) { // eslint-disable-next-line no-console console.error('Warning:', message); hasWarned = true; } } function getDisplayName(Comp) { var wrapper = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; var name = Comp.displayName || Comp.name; return !name || !wrapper ? name : "".concat(wrapper, "(").concat(name, ")"); } function injectable(from, implementation) { implementation.displayName = getDisplayName(implementation) || getDisplayName(from, 'di'); implementation[_constants.KEY] = from; return implementation; } /** @deprecated use injectable instead */ var mock = injectable; exports.mock = mock;