ulid / javascript

Universally Unique Lexicographically Sortable Identifier
MIT License
3.04k stars 107 forks source link

Added ability to seed the time component of the id #22

Closed jansenignacio closed 7 years ago

jansenignacio commented 7 years ago

I need a way to be able to migrate my old database to use ulid. In order for me to do that, I need to be able to seed the time component so that I can still sort the migrated data and new data using the id.

codecov-io commented 7 years ago

Codecov Report

Merging #22 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #22   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           2      2           
  Lines          78     86    +8     
  Branches        2      4    +2     
=====================================
+ Hits           78     86    +8
Impacted Files Coverage Δ
index.js 100% <100%> (ø) :arrow_up:
test.js 100% <100%> (ø) :arrow_up:

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 8413df4...f270cf0. Read the comment docs.

alizain commented 7 years ago

Great PR! Had a few thoughts on checking input, otherwise LGTM 👍

jansenignacio commented 7 years ago

Thanks! I've added type checking for seedTime, however if it is either 0, null, undefined, NaN, false, or anything else that returns true for !seedTime, the function will not throw an Error and just use the current Time as seed. Let me know if you want type checking to be more robust.