Skip to content

Conversation

@Phillip9587
Copy link
Member

Based on the work by @jonchurch in #606 and previous PRs listed in #22 (comment). Dicussion on this topic happened in #22.


There is one remaining point we need to figure out:

parse function

This PR in its current state passes the body as Buffer and the charset to the user provided parse function:

function customParse(buffer, charset) {
  // will only work if node.js supports this encoding else the user needs to use iconv-lite or similar libraries 
  const stringContent = buffer.toString(charset) 
  // custom parse method
}

With this approach we loose the iconv-lite decoding and the users would need to do that themselves . Should we instead already decode the body and pass it as string without the charset? Like:

function customParse(decodedBodyAsString) {
  // custom parse method
}

I think the most common use-case for the generic parser will be a custom string parser like parsing csv or yaml. Not some custom binary format. As alternative we could expose an option which switches between passing a Buffer or a already decoded string to the parse function.

cc @ctcpip @jonchurch @UlisesGascon @bjohansebas

Co-authored-by: Jon Church <me@jonchurch.com>
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.

1 participant