molszanski / iti

~1kB Dependency Injection Library for Typescript and React with a unique support of async flow
https://itijs.org
MIT License
129 stars 6 forks source link

delete operator #41

Closed jacoobes closed 1 year ago

jacoobes commented 1 year ago

Hi again,

From what I've read, using the delete operator is very slow. https://stackoverflow.com/questions/13982306/in-javascript-what-is-more-efficient-deleting-an-element-or-setting-it-to-undef.

Would you ever consider another alternative, like setting deleted properties to undefined? In addition, is there a reason to not use a Map instead of an object?

jacoobes commented 1 year ago

In addition, there might be some better ways I'm thinking about to tackle cache cleanup after a dependency is removed 👯

molszanski commented 1 year ago

The only reason for an object was typescript as it had a much better support for type inference. Do you see some performance problems related to deletion?

jacoobes commented 1 year ago

I haven't done full benchmarks for deletion but It's only an assumption it would be slower, so no i haven't add any problems

molszanski commented 1 year ago

Practically, I don't think there are any lib users who use for delete heavy operations. But I might be wrong ¯_(ツ)_/¯

jacoobes commented 1 year ago

true ¯(°_o)/¯

molszanski commented 1 year ago

But there are some other things I want to fix ^_^