-
Notifications
You must be signed in to change notification settings - Fork 13
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(utils): MIME 관련 유틸 함수 추가 #127
Conversation
🦋 Changeset detectedLatest commit: 0902a62 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
import { MIMEType, MIME_TYPES } from '../../file/constants'; | ||
|
||
export const isMIMEType = (type: string): type is MIMEType => { | ||
return MIME_TYPES.some((value) => value === type); |
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.
배열을 상수로서 as const
로 관리 할 경우 includes
메서드 활용 시 인자의 타입으로 string이면 타입 에러가 발생합니다 따라서 some으로 대체합니다.
💡 #128 PR에서 개선되었습니다
const result = getMIMETypeFromFile(file); | ||
expect(result).toBe(''); | ||
}); | ||
}); |
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.
getMIMETypeFromResponse, getMIMETypeFromUrl은 테스트 코드 작성이 쉽지 않아 우선 테스트 코드를 제외했습니다.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #127 +/- ##
==========================================
+ Coverage 92.97% 93.01% +0.04%
==========================================
Files 70 72 +2
Lines 626 630 +4
Branches 142 142
==========================================
+ Hits 582 586 +4
Misses 37 37
Partials 7 7
|
@ssi02014 고생많으셨습니다! 내용은 별도로 확인해보겠습니다! 👍👍👍 |
@Sangminnn 감사합니다 복잡도 있는 코드들은 아니어서 쉽게 파악이 될 것으로 생각됩니다 😄 |
console.error( | ||
`Failed to get the MIME type from the URL. message: ${err.message}` | ||
); | ||
return ''; |
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.
반환 타입을 string으로 맞춰주는 것이 사용성에 편할 것으로 판단해 빈 문자열을 반환하는 방향으로 작업하였습니다.
@Sangminnn #128 해당 PR에서 isMIMEType을 개선하였습니다. import { isString } from '../isString';
import { MIMEType, MIME_TYPES } from '../../file/constants';
export const isMIMEType = (arg: unknown): arg is MIMEType => {
return isString(arg) ? MIME_TYPES.some((value) => value === arg) : false;
}; |
Overview
#126
file과 관련된 유틸 함수를 관리하기 위해 file 폴더 추가했으며, MIME 타입을 얻을 수 있는 관련 유틸 함수를 추가합니다.
덤으로 isString, isMIMEType 함수도 추가하였습니다.
PR Checklist
Contributing Guide