Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print without serialization #58

Open
FGRibreau opened this issue May 5, 2022 · 0 comments
Open

Print without serialization #58

FGRibreau opened this issue May 5, 2022 · 0 comments

Comments

@FGRibreau
Copy link

Hello 👋

First thing first, sorry for this dummy question,

I have this transit string:

{"~:user/email":"[email protected]","~:user/uid":"OXeehCUcSCaglURUsQ","~:block/uid":"uqJ"}

that I would like to convert to:

[":user/email", "[email protected]", ":user/uid", "OXeehCUcSCaglURUsQ", ":block/uid", "uqJ"]

I've tried:

function mapToObj(transitMap) {
  // object with "~:xxx/xxx" keys:
  return mapKeys(writer.write(transitMap, { marshalTop: false }), (val, k) => k.replace(/^~:/, '')); // :O 
}

const convert = pipe(mapToObj, toPairs, flatten);

// usage:
convert(deserializedTransitString) => [..., ... ,...]

I've read most of the code of transit-js but could not find an easy way (beside relying a transform mapper when calling writer.write) to do this. Is this the only way or am I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant