@nebius/js-sdk - v0.2.54
    Preparing search index...

    Function createEnum

    • Creates the runtime class used by a generated protobuf enum.

      SDK generator output calls this function. Applications normally use the generated enum export instead of calling the factory.

      Type Parameters

      • TDef extends Record<string, number>

      Parameters

      • type: string

        Fully qualified protobuf enum name.

      • def: TDef

        Maps value names to numeric codes.

      • Optionalcomments: Record<string, string>

        Optional original protobuf comments by value name.

      Returns EnumClass<Extract<keyof TDef, string>>

      import { createEnum } from '@nebius/js-sdk/runtime/protos/enum';

      const State = createEnum('example.State', {
      STATE_UNSPECIFIED: 0,
      READY: 1,
      });

      State.READY.toNumber(); // 1
      State.fromJSON('READY') === State.READY; // true
      State.fromNumber(99).name; // "UNRECOGNIZED"