How to use the protobufjs.util.toObject function in protobufjs

To help you get started, we’ve selected a few protobufjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spotify / proto-registry / src / schema / parser.ts View on Github external
}
  const out = []
  for (const field of type.fieldsArray) {
    const key = field.name
    if (key !== 'uninterpretedOption') {
      if (options.hasOwnProperty(key)) { // eslint-disable-line no-prototype-builtins
        let val = options[key]
        if (field.resolvedType instanceof Enum && typeof val === 'number' &&
          field.resolvedType.valuesById[val] !== undefined) {
          val = field.resolvedType.valuesById[val]
        }
        out.push(underScore(key), val)
      }
    }
  }
  return out.length ? util.toObject(out) : undefined
}