UNPKG

annotated-graphql

Version:

Annotated GraphQL

25 lines (19 loc) 879 B
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; exports.getOrCreate = getOrCreate; exports.invariant = invariant; function getOrCreate(containerObject, propertyName, initialValues) { var propertyValue = containerObject[propertyName]; if ((typeof propertyValue === 'undefined' ? 'undefined' : _typeof(propertyValue)) != 'object') { propertyValue = containerObject[propertyName] = initialValues ? Object.assign({}, initialValues) : {}; } return propertyValue; } function invariant(condition, errorMessage) { if (!condition) { throw new Error(errorMessage); } }