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
remove p-defer and use crypto.randomUUID if available #38
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,17 @@ const emptyLogger = { | |
log: empty | ||
}; | ||
|
||
let uuidV4; | ||
const crypto = require('crypto'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can't use uuid from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is why I check in line 14 if the function is defined... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. right, so if you keep the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The randomUUID is 12 times faster but as you wish... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rluvaton just update to uuid version 9.. it will |
||
|
||
if (typeof crypto.randomUUID === 'function') { | ||
uuidV4 = () => crypto.randomUUID(); | ||
} else { | ||
// eslint-disable-next-line global-require | ||
const uuid = require('uuid'); | ||
uuidV4 = uuid.v4; | ||
} | ||
|
||
module.exports = { | ||
/** | ||
* Default transport to prevent any printing in the terminal | ||
|
@@ -44,5 +55,7 @@ module.exports = { | |
emitWarn.warned[code] = true; | ||
process.emitWarning(message, { code, detail }); | ||
} | ||
} | ||
}, | ||
|
||
uuidV4 | ||
}; |
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.
we actually had an own version of this, but decided to use this package to avoid managing custom version, so please lets keep it.
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.
No management is required in this it's just 4 lines of simple code...
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.
as explained earlier we had this already and it was decided to remove from the codebase,
p-defer
is commonly used package and downloaded 8 million times a day. Lets please stick with it.