handleProps.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. "use strict";
  2. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  3. function handleProps() {
  4. var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  5. opts.props = opts.props || {};
  6. if (opts.relations) {
  7. opts.props.theRelations = opts.relations;
  8. }
  9. if (!opts.properties) {
  10. return false;
  11. }
  12. Object.keys(opts.properties).forEach(function (prop) {
  13. var val = opts.properties[prop];
  14. if (!val) {
  15. opts.props[prop] = val;
  16. return false;
  17. }
  18. if (typeof val === 'function') {
  19. var _obj;
  20. var obj = (_obj = {}, _defineProperty(_obj, Boolean, false), _defineProperty(_obj, String, ''), _defineProperty(_obj, Array, []), _defineProperty(_obj, Object, {}), _obj);
  21. opts.props[prop] = obj[val];
  22. return false;
  23. }
  24. if (val.hasOwnProperty('value')) {
  25. opts.props[prop] = val.value;
  26. } else if (val.type !== 'observer') {
  27. var _info;
  28. var info = (_info = {}, _defineProperty(_info, String, ''), _defineProperty(_info, Number, 0), _defineProperty(_info, Object, {}), _defineProperty(_info, null, null), _info);
  29. opts.props[prop] = info[val.type];
  30. }
  31. });
  32. }
  33. module.exports = handleProps;