Skip to content
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

[Feature]: isReference, isPlainObject #218

Open
1 task done
ssi02014 opened this issue Jun 11, 2024 · 3 comments
Open
1 task done

[Feature]: isReference, isPlainObject #218

ssi02014 opened this issue Jun 11, 2024 · 3 comments
Assignees
Labels
feature 새로운 기능 추가 @modern-kit/utils @modern-kit/utils

Comments

@ssi02014
Copy link
Contributor

ssi02014 commented Jun 11, 2024

Package Scope

  • 기존 패키지에 기능 추가
  • Package name: @modern-kit/utils/validator

Overview

인자로 받은 value가 원시값이 아닌 참조형인지 판단하는 isReference 함수와 일반 객체인지 판단하는 isPlainObject

isReference({}); // true
isReference([]); // true
isReference(new Set()); // true
isReference(new Map()); // true
isPlainObject({}); // true
isPlainObject([]); // false
isPlainObject(new Set()); // false
isPlainObject(new Map()); // false
@ssi02014 ssi02014 added feature 새로운 기능 추가 @modern-kit/utils @modern-kit/utils labels Jun 11, 2024
@ssi02014 ssi02014 assigned ssi02014 and unassigned ssi02014 Jun 11, 2024
@Gaic4o
Copy link
Contributor

Gaic4o commented Jun 27, 2024

안녕하세요, 제가 isReferenceisPlainObject 유틸 함수를 구현해 보아도 될지 여쭙고 싶습니다!
감사합니다.

@ssi02014
Copy link
Contributor Author

ssi02014 commented Jun 27, 2024

@Gaic4o 라이브러리에 관심을 가져주셔서 정말 감사합니다 👍 작업자 할당했씁니다.

  1. isReference 는 사전에 작업된 isPrimitive을 활용해서 isPrimitive 반환 값의 부정!isPrimitive()을 반환하는 것을 생각했습니다.
  2. isPlainObject는 isReference 작업 후에 isReference(value) && value.constructor === Object를 생각했었습니다.
    • object로 타입가드 되야 함

위 생각은 참고용으로 봐주시고, 더 좋은 아이디어 및 방향성이 있다면 말씀해주세요! 감사합니다.
이슈가 묶여이긴 하지만 PR은 각각 생성해주시면 감사드릴게요!

@Gaic4o
Copy link
Contributor

Gaic4o commented Jun 27, 2024

좋은 훅과 유틸 함수를 제공해 주셔서 많이 배우고 있습니다.
친절한 답변과 작업 할당에 감사드립니다. 안내해 주신 내용으로 구현해 보도록 하겠습니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 새로운 기능 추가 @modern-kit/utils @modern-kit/utils
Projects
None yet
Development

No branches or pull requests

2 participants