[JS] Add `fromObject` method to take an AsObject type and return a T.
@lukesandberg がすでに取り組んでいます。
2022年3月11日 から。
評価
この issue はまだ評価されていません。
説明
What language does this apply to?
JS/TS
Describe the problem you are trying to solve.
In JS, many different libraries expect to work with dictionaries, basically Record<A, B> or lists of these, to do things like state management in single page apps, list operations like find, slice, zip, etc. and more. Having the ability to freely move between a Message and a JSON object would make it MUCH easier to interoperate with different tools.
Currently, my message types get compiled to something like the following:
export class Polygon extends jspb.Message {
// getters and setters here
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): Polygon.AsObject;
static toObject(includeInstance: boolean, msg: Polygon): Polygon.AsObject;
static serializeBinaryToWriter(message: Polygon, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): Polygon;
static deserializeBinaryFromReader(message: Polygon, reader: jspb.BinaryReader): Polygon;
}
Describe the solution you'd like
static fromObject(from: Polygon.AsObject): Polygon;
Describe alternatives you've considered
Writing a generic function to parse the field descriptors, but I don't know enough to make it work correctly, PLUS, it seems like a much better thing to be provided out of the box.
Additional context
- 主要言語
- JavaScript
- スター
- 471
- フォーク
- 91
- 平均マージ
- 3時間 57分
- マージ済み PR(30日)
- 2
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
protocolbuffers/protobuf-javascript のほかの issue
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
protocolbuffers/protobuf-javascript#248 · コメント 1 件 · リアクション 13 件 ·
-
question
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
protocolbuffers/protobuf-javascript#222 · コメント 9 件 ·
-
enhancement port-fix triaged
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
protocolbuffers/protobuf-javascript#185 · コメント 1 件 ·
-
enhancement port-fix triaged
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
protocolbuffers/protobuf-javascript#182 · コメント 3 件 · リアクション 1 件 ·
protocolbuffers/protobuf-javascript の issue をすべて見る
似ている issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
Mintplex-Labs/anything-llm#6490 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
-
[quality] workflow-scripts guard reads test:unit:coverage as skipping the unit suite, blocking #632 オープンagent/quality hive/hosted-available-lke648397-260827-5n31 quality testing
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
area-clientside-dartpad
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100