Skip to content

Conversation

@jungwoo3490
Copy link
Contributor

Overview

기존 excludeLastElement에서 배열의 마지막 요소를 const lastElement = array.at(-1); 과 같이 가져왔는데, 구형 브라우저나 런타임에서 Array.at()이 지원되지 않을 가능성이 있기 때문에 호환성 개선을 위해 배열의 마지막 요소를 가져오는 부분을 다음과 같이 수정하였습니다.

export function excludeLastElement(array: string[]): [string[], string] {
  const lastElement = array[array.length - 1]; // fixed
  return [array.slice(0, -1), lastElement ?? ''];
}

PR Checklist

  • I read and included theses actions below
  1. I have read the Contributing Guide
  2. I have written documents and tests, if needed.

@changeset-bot
Copy link

changeset-bot bot commented May 2, 2024

🦋 Changeset detected

Latest commit: 5c47630

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented May 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
es-hangul ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 3, 2024 1:54pm

@jungwoo3490 jungwoo3490 changed the title fix: 호환성 개선을 위해 배열의 마지막 요소 가져오는 부분 수정 fix: 호환성 개선을 위해 배열의 마지막 요소 가져오는 로직 수정 May 2, 2024
okinawaa
okinawaa previously approved these changes May 3, 2024
Copy link
Member

@okinawaa okinawaa left a comment

Choose a reason for hiding this comment

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

좋습니다!
실제 컴파일된 결과물을 확인해봐도(.js, .mjs), at(-1) 코드가 그대로 남아있네요!

@okinawaa okinawaa merged commit 1292575 into toss:main May 3, 2024
@github-actions github-actions bot mentioned this pull request May 9, 2024
@jungwoo3490 jungwoo3490 changed the title fix: 호환성 개선을 위해 배열의 마지막 요소 가져오는 로직 수정 fix: excludeLastElement 호환성 개선 - 배열의 마지막 요소 가져오는 로직 수정 May 28, 2024
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