diff --git a/.changeset/ninety-bobcats-switch.md b/.changeset/ninety-bobcats-switch.md new file mode 100644 index 00000000..b72ae7cf --- /dev/null +++ b/.changeset/ninety-bobcats-switch.md @@ -0,0 +1,5 @@ +--- +"@nft-team/core": minor +--- + +refactor(@nft-team/core): 유틸함수 변수명 변경 (`removeNullable`, `checkNumber`) diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index e22ae112..e313f9a9 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -1,4 +1,4 @@ export { - checkEmpty, checkNull, checkNumNull, emptyAThenB, generateArrayOfNumber, - isEmpty, trueOrFalse, + checkEmpty, checkNumber, emptyAThenB, generateArrayOfNumber, + isEmpty, removeNullable, trueOrFalse, } from './utils'; diff --git a/packages/core/src/utils.test.ts b/packages/core/src/utils.test.ts index 0a60d2e2..ff6cef7e 100644 --- a/packages/core/src/utils.test.ts +++ b/packages/core/src/utils.test.ts @@ -1,18 +1,18 @@ import { checkEmpty, - checkNull, - checkNumNull, + checkNumber, emptyAThenB, generateArrayOfNumber, isEmpty, + removeNullable, trueOrFalse, } from './utils'; -describe('checkNull', () => { +describe('removeNullable', () => { context('value가 null일 경우', () => { context('replacementValue가 존재하지 않는 경우', () => { it('빈 문자열을 반환해야만 한다', () => { - const result = checkNull(null); + const result = removeNullable(null); expect(result).toBe(''); }); @@ -20,7 +20,7 @@ describe('checkNull', () => { context('replacementValue가 존재하는 경우', () => { it('대체할 문자열(두 번째 인자)을 반환해야만 한다', () => { - const result = checkNull(undefined, '-'); + const result = removeNullable(undefined, '-'); expect(result).toBe('-'); }); @@ -29,17 +29,17 @@ describe('checkNull', () => { context('value가 null이 아닌 경우', () => { it('입력된 값이 반환되어야만 한다', () => { - const result = checkNull('nana'); + const result = removeNullable('nana'); expect(result).toBe('nana'); }); }); }); -describe('checkNumNull', () => { +describe('checkNumber', () => { context('value가 null인 경우', () => { it('0을 반환해야 한다', () => { - const result = checkNumNull(0); + const result = checkNumber(null); expect(result).toBe(0); }); @@ -47,7 +47,7 @@ describe('checkNumNull', () => { context('value가 null이 아닌 경우', () => { it('입력된 값이 반환되어야 한다', () => { - const result = checkNumNull(100); + const result = checkNumber(100); expect(result).toBe(100); }); diff --git a/packages/core/src/utils.ts b/packages/core/src/utils.ts index ff8517b5..2345bdb1 100644 --- a/packages/core/src/utils.ts +++ b/packages/core/src/utils.ts @@ -1,4 +1,4 @@ -export const checkNull = (value?: string | null, replacementValue?: string): string => { +export const removeNullable = (value?: string | null, replacementValue?: string): string => { if (value) { return value; } @@ -10,12 +10,12 @@ export const checkNull = (value?: string | null, replacementValue?: string): str return ''; }; -export const checkNumNull = (value?: number | null): number => { - if (!value) { - return 0; +export const checkNumber = (value?: number | null): number => { + if (typeof value === 'number') { + return value; } - return value; + return 0; }; export const emptyAThenB = (b: string, a?: string | null): string => a || b;