You have a few options. @infu was sharing on Discord about a JS parser they’ve been writing from scratch in the Discord channel.
We have some tools, like ic0 - npm and @infu/icblast - npm which currently compile the didc tool to run in webassembly, and they also have some simplified interfaces for making calls to those canisters after the fact.
If you want to stick with agent-js, here is a little snippet that makes a call to the Candid UI canister to do the conversion from did for you. This is how Candid UI and the Candid UI web component parse did files into JS
Candid is interface description language. What you want to parse isn’t valid Candid. It seems you are trying to parse data. Unless “A” is another type identifier, but then it should probably be record : { name : “A” }
You can use - didc check file.did to see if its valid first. You can dl it from the Candid github repo.
The only time you will need candid-js is probably if you are making IC browser. If you just want to encode with a spec, then the rest of the tools like agentjs will get it done
Ok after reading your initial post, there is textual data format used in dfx for example, but I am not sure where the encoders for it are. To covert obj to binary using candid you can use IDL.encode(jsIdl, data) also there is IDL.decode. You have to take the jsIdl out of the idlFactory function