util.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. "use strict";
  2. // Copyright 2021 Google LLC
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. Object.defineProperty(exports, "__esModule", { value: true });
  16. exports.assert = exports.wrapperTypes = exports.getFullyQualifiedTypeName = void 0;
  17. function getFullyQualifiedTypeName(type) {
  18. // We assume that the protobuf package tree cannot have cycles.
  19. let fullyQualifiedTypeName = '';
  20. while (type.parent) {
  21. fullyQualifiedTypeName = `.${type.name}${fullyQualifiedTypeName}`;
  22. type = type.parent;
  23. }
  24. return fullyQualifiedTypeName;
  25. }
  26. exports.getFullyQualifiedTypeName = getFullyQualifiedTypeName;
  27. exports.wrapperTypes = new Set([
  28. '.google.protobuf.DoubleValue',
  29. '.google.protobuf.FloatValue',
  30. '.google.protobuf.Int64Value',
  31. '.google.protobuf.UInt64Value',
  32. '.google.protobuf.Int32Value',
  33. '.google.protobuf.UInt32Value',
  34. '.google.protobuf.BoolValue',
  35. '.google.protobuf.StringValue',
  36. '.google.protobuf.BytesValue',
  37. ]);
  38. function assert(assertion, message) {
  39. if (!assertion) {
  40. throw new Error(message);
  41. }
  42. }
  43. exports.assert = assert;
  44. //# sourceMappingURL=util.js.map