From 5b72b05296bc5a87999243eb3f9a9be2157ab9ba Mon Sep 17 00:00:00 2001 From: saseungmin Date: Thu, 20 Jul 2023 01:24:52 +0900 Subject: [PATCH 1/2] =?UTF-8?q?refactor(@nft-team/core):=20=EC=9C=A0?= =?UTF-8?q?=ED=8B=B8=ED=95=A8=EC=88=98=20=EB=B3=80=EC=88=98=EB=AA=85=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/index.ts | 4 ++-- packages/core/src/utils.test.ts | 18 +++++++++--------- packages/core/src/utils.ts | 10 +++++----- 3 files changed, 16 insertions(+), 16 deletions(-) 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; From 6d287ed2ba4745e1c7caf8893447dbe91ac798e9 Mon Sep 17 00:00:00 2001 From: Harang Date: Thu, 20 Jul 2023 01:27:05 +0900 Subject: [PATCH 2/2] docs: @nft-team/core minor version --- .changeset/ninety-bobcats-switch.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/ninety-bobcats-switch.md 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`)