Skip to content

Support re-encoding of indefinite length types.#113

Open
mesudip wants to merge 1 commit into
kriszyp:masterfrom
mesudip:feat/indefinite-re-encoding
Open

Support re-encoding of indefinite length types.#113
mesudip wants to merge 1 commit into
kriszyp:masterfrom
mesudip:feat/indefinite-re-encoding

Conversation

@mesudip

@mesudip mesudip commented Sep 10, 2024

Copy link
Copy Markdown

Why

Its important for my use-case that re-encoding some portion of decoded data creates the same binary.

What

When decoding indefinite length array, text, binary or map,

  • return a proxy of the type
  • retain the original segments so that it can be re-encoded to same data.
  • when encoding, if a flag is set, use the indefinite length encoding.

@mesudip mesudip force-pushed the feat/indefinite-re-encoding branch from 660244f to 3051cf6 Compare September 10, 2024 09:14
Comment thread decode.js
if(prop == 'constructor'){
return target[prop]
}
return (combinedString[prop]).bind(combinedString);

@Mudloop Mudloop Jul 4, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to use Reflect.get instead of manually binding, it might handle some edge cases.
But instead of using a proxy, why not just :

Object.assign(combinedString, { _cbor_indef: strings });

That will probably be a little more performant
EDIT : didn't notice this was old-ish

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

Successfully merging this pull request may close these issues.

2 participants