[JS] Add `fromObject` method to take an AsObject type and return a T.
@lukesandberg ci sta già lavorando.
Dal 11/3/2022.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
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
- Lingua principale
- JavaScript
- Stelle
- 471
- Fork
- 91
- Merge medio
- 3h 57m
- PR unite (30g)
- 2
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di protocolbuffers/protobuf-javascript
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
protocolbuffers/protobuf-javascript#248 · 1 commento · 13 reazioni ·
-
question
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
protocolbuffers/protobuf-javascript#222 · 9 commenti ·
-
Why map.js sort keys? Apertaenhancement port-fix triaged
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
protocolbuffers/protobuf-javascript#185 · 1 commento ·
-
enhancement port-fix triaged
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
protocolbuffers/protobuf-javascript#182 · 3 commenti · 1 reazione ·
Tutte le issue di protocolbuffers/protobuf-javascript
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
avniproject/avni-client#2135 ·
-
automated broken-link
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
-
agent/security hive/hosted-available-lke648397-260827-5n31 security
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
babalae/bettergi-scripts-list#3674 ·
-
A-Release-Notes C-Editing D-Modest S-Ready-For-Implementation
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
bevyengine/bevy-website#2595 ·