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

Version 9 improvements #464

Merged
merged 18 commits into from
Jun 24, 2020
Merged

Version 9 improvements #464

merged 18 commits into from
Jun 24, 2020

Conversation

broofa
Copy link
Member

@broofa broofa commented Jun 2, 2020

This started out as a variation of #463 (uuidToBytes implementation), but now includes the following per discussion in this PR:

  • Rename uuidToBytes() -> stringify()
  • Rename bytesToUuid() -> parse()
  • parse() (was uuidToBytes()) now returns Uint8Array
  • Expose version(), validate(), parse(), and stringify() as part of public API
  • Unit tests and benchmarks for stringify() and parse()
  • Document new methods in README

@broofa broofa mentioned this pull request Jun 2, 2020
@broofa broofa marked this pull request as ready for review June 2, 2020 16:54
@broofa broofa changed the title fix: fast and compact uuidToBytes fix: fast (and compact-ish) uuidToBytes Jun 2, 2020
@broofa broofa requested a review from ctavan June 2, 2020 17:02
@broofa broofa force-pushed the uuidToBytes_fast branch from e9eed5a to 98b74e8 Compare June 2, 2020 17:07
@broofa
Copy link
Member Author

broofa commented Jun 11, 2020

Pushing forward with this approach. I can move relevant work to #463 if we decide to go with that.

  • Pulled uuidToBytes into separate file
  • uuidToBytes unit test
  • Added uuidToBytes to exports
  • Added benchmark for uuidToBytes.

Copy link
Member

@ctavan ctavan left a comment

Choose a reason for hiding this comment

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

LvGTM (once the minor nits in the test + naming are solved).

@broofa
Copy link
Member Author

broofa commented Jun 12, 2020

Comments look good, @ctavan. I'm out of town until wednesday, however, so may not be able to get to this until then.

@broofa broofa force-pushed the uuidToBytes_fast branch from c559c21 to f2c57b9 Compare June 23, 2020 18:29
@broofa broofa force-pushed the uuidToBytes_fast branch from f2c57b9 to 2629e4e Compare June 23, 2020 18:47
@broofa broofa changed the title fix: fast (and compact-ish) uuidToBytes Version 9 improvements Jun 23, 2020
@broofa broofa requested review from LinusU, TrySound and ctavan June 23, 2020 19:00
@broofa
Copy link
Member Author

broofa commented Jun 23, 2020

Adding @LinusU and @TrySound as reviewers, as there's been a bit of feature creep here.

Requesting re-review from @ctavan because switching to Uint8Array for parse() has resulted in a few changes elsewhere in the code. Also, it's worth noting that this change reduced the benchmark performance of parse() by ~25%.

@broofa
Copy link
Member Author

broofa commented Jun 23, 2020

@ctavan: Note that the UMD version of the API has uuid prefixed on the new methods. So, uuidVersion, uuidParse, uuidParse(), and uuidStringify(). This is mostly consistent with the existing uuidv1 methods. (The unprefixed names felt a bit too generic to export as globals so... 😕 ). Let me know if you have a better idea for how to handle this.

Edit: Also, what's up with the failing webdriver tests? Is that just browserwatch being flakey?

Copy link
Member

@ctavan ctavan left a comment

Choose a reason for hiding this comment

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

Looks good!

A second review by @LinusU or @TrySound would be really welcome!

@ctavan
Copy link
Member

ctavan commented Jun 23, 2020

@ctavan: Note that the UMD version of the API has uuid prefixed on the new methods. So, uuidVersion, uuidParse, uuidParse(), and uuidStringify(). This is mostly consistent with the existing uuidv1 methods. (The unprefixed names felt a bit too generic to export as globals so... 😕 ). Let me know if you have a better idea for how to handle this.

Not really a better idea. Consistent would be uuidversion but that doesn't read well… I consider the umd build really just an optional feature e.g. for educational purposes where people do online coding courses or things like that, so I'm not so much afraid about the api surface on that end.

Also, with cool things like jspm there seems to be a modern alternative for the direct browser loading use case.

So maybe just not expose these methods in the umd build at all until somebody complains?

Edit: Also, what's up with the failing webdriver tests? Is that just browserwatch being flakey?

Test fail in the old browsers:

  • IE11
  • Firefox 44
  • Chrome 49

String.padStart() seems to be the culprit:

1592943821280:SEVERE:http://127.0.0.1:9000/browser-webpack/dist/all.js 1:991 Uncaught TypeError: o.toString(...).padStart is not a function
,1592943821339:SEVERE:http://127.0.0.1:9000/favicon.ico 0:0 Failed to load resource: the server responded with a status of 404 (Not Found)
,1592943831873:SEVERE:http://127.0.0.1:9000/browser-webpack/dist/v1.js 1:992 Uncaught TypeError: o.toString(...).padStart is not a function
,1592943842443:SEVERE:http://127.0.0.1:9000/browser-webpack/dist/v4.js 1:992 Uncaught TypeError: o.toString(...).padStart is not a function
,1592943852840:SEVERE:http://127.0.0.1:9000/browser-rollup/dist/all.js 1:465 Uncaught TypeError: u.toString(...).padStart is not a function
,1592943863391:SEVERE:http://127.0.0.1:9000/browser-rollup/dist/v1.js 1:465 Uncaught TypeError: u.toString(...).padStart is not a function
,1592943873923:SEVERE:http://127.0.0.1:9000/browser-rollup/dist/v4.js 1:461 Uncaught TypeError: r.toString(...).padStart is not a function

@broofa
Copy link
Member Author

broofa commented Jun 23, 2020

@ctavan Where are you seeing those webdriver error messages? I'm not seeing anything like that in the github "checks" logs (e.g. https://github.com/uuidjs/uuid/pull/464/checks?check_run_id=801127791). All I see are timeout errors.

@ctavan
Copy link
Member

ctavan commented Jun 23, 2020

I got those console errors from the Browserstack UI. Last time I think I had issues inviting you to my Open Source team there. Shall I give that another try?

Seems like now it's Chrome 49 and IE 11 that are broken, however this time I don't get meaningful console errors from Browserstack.

However this screenshot:
image

tells me that something in v5() must be broken because all lines up until

addTest('uuidv5() DNS', uuidv5('hello.example.com', uuidv5.DNS));
seem to render fine.

@broofa
Copy link
Member Author

broofa commented Jun 23, 2020

Temporary browserstack workaround: Building and pushing to my personal site, then doing manual testing there. It's not great but I've figured out the immediate issue (No Array.from on IE11). All checks passing.

Copy link
Member

@LinusU LinusU left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Co-authored-by: Linus Unnebäck <linus@folkdatorn.se>
@broofa broofa merged commit 3d24e58 into v9 Jun 24, 2020
@broofa broofa deleted the uuidToBytes_fast branch June 24, 2020 14:52
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.

4 participants