-
Notifications
You must be signed in to change notification settings - Fork 277
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
Conversation
@minchodang is attempting to deploy a commit to the Toss Team on Vercel. A member of the Team first needs to authorize it. |
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); | ||
}); | ||
}); |
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.
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[]`): 마지막 요소를 제외한 나머지 요소들로 구성된 새로운 배열을 반환할 배열. |
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.
- `arr`(`T[]`): 마지막 요소를 제외한 나머지 요소들로 구성된 새로운 배열을 반환할 배열. | |
- `arr`(`T[]`): 마지막 요소를 제외할 배열. |
I guess it's better for us to simplify this description.
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.
Looks great. Thanks!
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