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

feat(node): Remove lru_map dependency #9300

Merged
merged 2 commits into from
Oct 18, 2023

Conversation

timfish
Copy link
Collaborator

@timfish timfish commented Oct 18, 2023

Ref #9199

This PR:

  • Adds a simple LRUMap to utils
    • Considerably smaller and simpler than lru_map
    • Map.prototype.keys() returns an iterator in order of insertion so the oldest entry key is keys().next().value
  • Replaces all usages of lru_map

We could add LRUMap to @sentry/node but it might be useful elsewhere and it's required in the Electron SDK and it would be better not to add an export to a public API.

Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

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

nice, good change!

},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.5",
Copy link
Member

Choose a reason for hiding this comment

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

was this this just there for lru_map?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep!

public values(): Array<V> {
const values: V[] = [];
this._cache.forEach(value => values.push(value));
return values;
Copy link
Member

Choose a reason for hiding this comment

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

why this over Array.from(this._cache.values())?

Copy link
Collaborator Author

@timfish timfish Oct 18, 2023

Choose a reason for hiding this comment

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

That triggers a lint:

ES6 methods not allowed: valueseslint(@sentry-internal/sdk/no-unsupported-es6-methods)

This method is currently only used by some tests...

@AbhiPrasad AbhiPrasad merged commit da339b4 into getsentry:develop Oct 18, 2023
70 checks passed
AbhiPrasad pushed a commit that referenced this pull request Oct 18, 2023
@timfish timfish deleted the feat/remove-lru_map-dep branch December 13, 2023 09:14
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.

2 participants