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

Universal ts lib moving last array utils method from node core #331

Conversation

CarlosGamero
Copy link
Collaborator

@CarlosGamero CarlosGamero commented Sep 18, 2024

Changes

Please describe

Checklist

  • Apply one of following labels; major, minor, patch or skip-release
  • I've updated the documentation, or no changes were necessary
  • I've updated the tests, or no changes were necessary

@CarlosGamero CarlosGamero self-assigned this Sep 18, 2024
Comment on lines 2 to 6
export async function callChunked<Item>(
chunkSize: number,
array: readonly Item[],
processFn: (arrayChunk: Item[]) => Promise<unknown>,
): Promise<void> {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

With this one, all array utils from node-core are already here, so we plan removing them from there

Comment on lines +2 to +3
* @deprecated Use `areArraysEqual` instead.
*
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought that we can have something more common, and not only for string arrays

Comment on lines +1 to +6
/**
* Check if two arrays are equal.
* The arrays are considered equal if they have the same length, same order and the elements at each index by value are equal.
* Note: Equality is compared by value and not by reference.
*/
export function areArraysEqual(a: unknown[], b: unknown[]): boolean {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thinking about having areEquals so it can be also used to compare objects, still thinking about it

Copy link
Collaborator

Choose a reason for hiding this comment

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

from perf perspective separate functions are better, because isomorphic params (different structure across multiple calls) will cause v8 to deoptimize.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am not sure, my idea was to have something like:

areEquals(a: unknown, b: unknown): boolean

it won't use isomorphic params but not sure if v8 will deoptimize it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As an example -> db19fb8

@CarlosGamero
Copy link
Collaborator Author

Will open a new PR with final version

@CarlosGamero CarlosGamero deleted the feature/universal_ts_lib_moving_array_utils_from_node-core branch September 28, 2024 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants