Skip to content

Conversation

hhsnopek
Copy link

@hhsnopek hhsnopek commented Feb 15, 2018

NOTE: the package.json edits were made by yarn/npm installation

Summary

This pull request normalizes encodings between node and the browser. By doing so we eliminate any malformed data and introduce a stable utf8 encoding/decoding library which improves stability between both environments.

Updates

  • Add utf8.js
  • Add Buffer
  • Simplify and normalize encoding/decoding process

@codecov-io
Copy link

Codecov Report

Merging #9 into master will increase coverage by 7.14%.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##           master     #9      +/-   ##
========================================
+ Coverage   92.85%   100%   +7.14%     
========================================
  Files           3      1       -2     
  Lines          42     14      -28     
========================================
- Hits           39     14      -25     
+ Misses          3      0       -3
Impacted Files Coverage Δ
src/reshape-ast-to-vdom.js

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bef6e1f...afa4360. Read the comment docs.

Copy link
Member

@jescalan jescalan left a comment

Choose a reason for hiding this comment

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

So, I'd like to figure out how we can make this happen, but before I merge this I'd want to determine why we have passing tests for unicode encode/decode, but it is still not working in your case.

This solution, while nice and clean, adds two additional fairly large dependencies that will be pulled down on the client side, and have a performance impact on all sites that implement this library. The current solution adds minimal code and no extra dependencies, and so if the tests are passing and it's working, I'd prefer to avoid the extra weight if possible.

I know this is a super late review, just was revisiting this and I do want to make sure it has been resolved at some point.

}
module.exports.encode = encode
const utf8 = require('utf8')
const Buffer = require('buffer/').Buffer
Copy link
Member

Choose a reason for hiding this comment

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

typo here, no idea how tests would be passing

Copy link
Author

Choose a reason for hiding this comment

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

I'm guessing you're referring to the / in the require? this forces node to look inside node_modules instead of using buffer from the internal api

@hhsnopek
Copy link
Author

The current tests are rather bare and should have included a larger set of Unicode characters from Unicode 6.0.0 standard. The provided solution here does work and is used in a production setting. I'm unable to allocate time to this currently, however, if I wind-up with free time in the future I can revisit this and add more tests.

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.

3 participants