Skip to content

perf: optimize buffer input processing - #4

Merged
antongolub merged 5 commits into
webpod:mainfrom
easymikey:feat-proccessing-buffers
Jan 10, 2025
Merged

antongolub merged 5 commits into
webpod:mainfrom
easymikey:feat-proccessing-buffers

Conversation

@easymikey

Copy link
Copy Markdown
Contributor

Fix #2

  • Tests

@easymikey

Copy link
Copy Markdown
Contributor Author

@antongolub Look like it's time

@antongolub antongolub left a comment

Copy link
Copy Markdown
Member

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

Comment thread src/main/ts/envapi.ts Outdated
const Q2 = "'" // single quote
const Q3 = '`' // backtick

const utf8Decoder = new TextDecoder('utf-8')

@antongolub antongolub Jan 10, 2025 •

Copy link
Copy Markdown
Member

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
Copy Markdown
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

Comment thread src/main/ts/envapi.ts Outdated
}

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

@antongolub antongolub Jan 10, 2025 •

Copy link
Copy Markdown
Member

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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

UP

Comment thread src/test/ts/index.test.ts Outdated
JSONSTR='{"foo": "b a r"}'`
)
})
test("works with buffer with different encoding", () => {

Copy link
Copy Markdown
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

@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
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