-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Refactoring (v3) #96
Refactoring (v3) #96
Conversation
@Eomm const { createWarning } = require('..')
const CUSTDEP001 = createWarning('DeprecationWarning', 'CUSTDEP001', 'This is a deprecation warning')
CUSTDEP001() ? |
And how do you check if it has been emitted? |
CUSTDEP001.emitted ? |
I don't think switching to a class is needed, using a closure or function would be sufficient and avoid less changes. |
Did a quick test without class, and the performance was worse.
TBH I don't like too much props attached to a function. I can't see any advantages, plus I expect the typings are more hard to write |
I find this odd when considering how JavaScript works. A function is an object like any other. |
in this case, where we don't have constraints, and we are defining a new API, so I think that having a more expressive |
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.
lgtm
Need help for TS 😅 |
Ok, will do now the TS part |
Fixed typings |
Good to go or strong against this API? |
Co-authored-by: Aras Abbasi <aras.abbasi@googlemail.com>
This comment was marked as outdated.
This comment was marked as outdated.
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.
LGTM
Imho object param for constructor/factry is preferable I am inconclusive regarding the payload for instanciating. Could mean that we need to create unnecessary intermediary arrays. |
I would generically prefer a functional pattern instead of a classical one: const emit = createWarning(..)
emit(...)
if (emit.emitted) { ... } This is just personal preference. |
Me too, but There is a performance bottleneck to implement it as functional, because the function name has to be set via Object.defineProperty. So we get from 220 mio ops/s and get 86 mio ops/s on my machine. |
This is what the PR implements, correct?
I don't follow. What has to be defined? Personally, I don't think there is any need to sacrifice good api/developer experience in the name of "performance" here. These entities are going to be created at application initialization more often than not, and once created will perform as well as any other event emitter. |
See here: |
Co-authored-by: James Sumners <321201+jsumners@users.noreply.github.com>
A bit different, there is the
Fixing the input object |
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.
lgtm
I could remove the bottleneck in #97 |
Co-authored-by: Aras Abbasi <aras.abbasi@googlemail.com> Co-authored-by: James Sumners <321201+jsumners@users.noreply.github.com>
I think the last open discussion point is if unlimited should be true by default or not. I have no strong opinion on this. |
I'll do a pass on the docs and examples after this is merged. None of my feedback has been blocking. |
fixes #95, #88
New Bench:
Master branch:
TODO