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

perf: optimize buffer input processing #4

Merged
merged 5 commits into from
Jan 10, 2025

Conversation

easymikey
Copy link
Contributor

Fix #2

  • Tests

@easymikey
Copy link
Contributor Author

@antongolub Look like it's time

Copy link
Member

@antongolub antongolub left a comment

Choose a reason for hiding this comment

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

Add nodejs v7 to test matrix

@@ -6,6 +6,15 @@ const Q1 = '"' // double quote
const Q2 = "'" // single quote
const Q3 = '`' // backtick

const utf8Decoder = new TextDecoder('utf-8')
Copy link
Member

@antongolub antongolub Jan 10, 2025

Choose a reason for hiding this comment

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

const {decode} = new TextDecoder('utf-8')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It won't work that way and I don't want to bind

TypeError [ERR_INVALID_THIS]: Value of "this" must be of type TextDecoder

@@ -22,7 +31,7 @@ export const parse = (content: string | Buffer): NodeJS.ProcessEnv => {
}
}

for (const c of content.toString().replace(/\r\n?/mg, '\n')) {
for (const c of bufToString(content).toString().replace(/\r\n?/mg, '\n')) {
Copy link
Member

@antongolub antongolub Jan 10, 2025

Choose a reason for hiding this comment

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

for (const c of (typeof content === 'string' ? content : decode(content))) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

UP

@@ -70,6 +70,44 @@ JSON='{"foo": "b a r"}'
JSONSTR='{"foo": "b a r"}'`
)
})
test("works with buffer with different encoding", () => {
Copy link
Member

Choose a reason for hiding this comment

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

To verbose. Check typecast, not all cases. FOO=BAR\r\nBAZ=QUZ is enough

@easymikey easymikey force-pushed the feat-proccessing-buffers branch from 77e8d2b to 97cf634 Compare January 10, 2025 11:24
@easymikey easymikey force-pushed the feat-proccessing-buffers branch from 97cf634 to 5d0d111 Compare January 10, 2025 11:26
@antongolub antongolub changed the title refactor: samantic proccesing of buffer perf: optimize buffer input processing Jan 10, 2025
@antongolub antongolub merged commit a057e38 into webpod:main Jan 10, 2025
6 checks passed
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.

feat: improve handling string or buffer
2 participants