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(initial): add initial #188

Merged
merged 4 commits into from
Jul 14, 2024
Merged

feat(initial): add initial #188

merged 4 commits into from
Jul 14, 2024

Conversation

minchodang
Copy link
Contributor

@minchodang minchodang commented Jul 14, 2024

close #151 #95

description

I have created a function that returns a new array containing all elements except the last one from the input array.
Below is a performance comparison with Lodash. If you have any questions or comments, please feel free to share.

Thank you.

benchmark

스크린샷 2024-07-13 오후 10 58 40

Copy link

vercel bot commented Jul 14, 2024

@minchodang is attempting to deploy a commit to the Toss Team on Vercel.

A member of the Team first needs to authorize it.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (6606d5b) to head (7a93924).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #188   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           78        79    +1     
  Lines          427       431    +4     
  Branches        59        60    +1     
=========================================
+ Hits           427       431    +4     

@minchodang minchodang changed the title feat(initial): add initial feat(initial): add initial Jul 14, 2024
Comment on lines +1 to +20
import { bench, describe } from 'vitest';
import { initial as lodashInitial } from 'lodash';
import { initial as esToolkitInitial } from 'es-toolkit'; // hypothetical library

// Helper function to generate a large array
function generateLargeArray(size) {
return Array.from({ length: size }, (_, index) => index);
}

describe('initial function performance', () => {
const largeArray = generateLargeArray(1000000); // 1 million elements

bench('es-toolkit/initial', () => {
esToolkitInitial(largeArray);
});

bench('lodash/initial', () => {
lodashInitial(largeArray);
});
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
import { bench, describe } from 'vitest';
import { initial as lodashInitial } from 'lodash';
import { initial as esToolkitInitial } from 'es-toolkit'; // hypothetical library
// Helper function to generate a large array
function generateLargeArray(size) {
return Array.from({ length: size }, (_, index) => index);
}
describe('initial function performance', () => {
const largeArray = generateLargeArray(1000000); // 1 million elements
bench('es-toolkit/initial', () => {
esToolkitInitial(largeArray);
});
bench('lodash/initial', () => {
lodashInitial(largeArray);
});
});
import { bench, describe } from 'vitest';
import { initial as initialLodash } from 'lodash';
import { initial as initialToolkit } from 'es-toolkit'; // hypothetical library
// Helper function to generate a large array
function generateLargeArray(size) {
return Array.from({ length: size }, (_, index) => index);
}
describe('initial function performance', () => {
const largeArray = generateLargeArray(1000000); // 1 million elements
bench('es-toolkit/initial', () => {
initialToolkit(largeArray);
});
bench('lodash/initial', () => {
initialLodash(largeArray);
});
});

I think it's better for us to follow other benchmarks.


### 파라미터

- `arr`(`T[]`): 마지막 요소를 제외한 나머지 요소들로 구성된 새로운 배열을 반환할 배열.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- `arr`(`T[]`): 마지막 요소를 제외한 나머지 요소들로 구성된 새로운 배열을 반환할 배열.
- `arr`(`T[]`): 마지막 요소를 제외할 배열.

I guess it's better for us to simplify this description.

Copy link
Collaborator

@raon0211 raon0211 left a comment

Choose a reason for hiding this comment

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

Looks great. Thanks!

@raon0211 raon0211 merged commit 15a1a3c into toss:main Jul 14, 2024
6 of 7 checks passed
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.

Support for initial
3 participants