-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
@antongolub Look like it's time |
There was a problem hiding this 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
src/main/ts/envapi.ts
Outdated
@@ -6,6 +6,15 @@ const Q1 = '"' // double quote | |||
const Q2 = "'" // single quote | |||
const Q3 = '`' // backtick | |||
|
|||
const utf8Decoder = new TextDecoder('utf-8') |
There was a problem hiding this comment.
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')
There was a problem hiding this comment.
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
src/main/ts/envapi.ts
Outdated
@@ -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')) { |
There was a problem hiding this comment.
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))) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UP
src/test/ts/index.test.ts
Outdated
@@ -70,6 +70,44 @@ JSON='{"foo": "b a r"}' | |||
JSONSTR='{"foo": "b a r"}'` | |||
) | |||
}) | |||
test("works with buffer with different encoding", () => { |
There was a problem hiding this comment.
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
77e8d2b
to
97cf634
Compare
97cf634
to
5d0d111
Compare
Fix #2