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]: isSubset #306

Closed
1 of 2 tasks
beberiche opened this issue Jul 5, 2024 · 1 comment · Fixed by #309
Closed
1 of 2 tasks

[Feature]: isSubset #306

beberiche opened this issue Jul 5, 2024 · 1 comment · Fixed by #309
Assignees
Labels
feature 새로운 기능 추가 @modern-kit/utils @modern-kit/utils

Comments

@beberiche
Copy link
Contributor

beberiche commented Jul 5, 2024

Package Scope

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

Overview

첫번째 인자로 주어지는 배열 요소들을 기준으로 두번째 인자로 주어지는 배열 요소들을 완전히 포함하는지(부분집합)에 대한 유무를 반환합니다.
라이브러이에 합집합, 차집합, 교집합은 구현이 완료되어 있으나, 부분집합은 없는 듯하여 아이디어를 내봅니다.

const arr1 = [1,2,3,4,5];
const arr2 = [1,3];
const arr3 = [6,7,8];

console.log(isSubset(arr1, arr2)); // true
console.log(isSubset(arr1, arr3)); // true
@ssi02014 ssi02014 self-assigned this Jul 5, 2024
@ssi02014 ssi02014 added feature 새로운 기능 추가 @modern-kit/utils @modern-kit/utils labels Jul 5, 2024
@ssi02014
Copy link
Contributor

ssi02014 commented Jul 5, 2024

@beberiche 너무 좋은 아이디어 같습니다 의견 감사합니다!
단, 추가적인 의견으로 각 요소들이 원시값뿐만 아니라 참조형일 때도 3번째 인자인 iteratee를 통해 해당 함수 결과값으로 판단하는게 추가 되면 조흘 것 같습니다.

예를 들어 아래와 같습니다.

const arr1 = [{ id: 1}, { id: 2 }, {id: 3}];
const arr2 = [{ id: 1}, { id: 2 }];

isSubset(arr1, arr2, (item) => item.id); // true

또한 작업 폴더는 validator로 진행해주시면 감사드립니다 🙏
효율성을 위해 set과 iteratee 여부를 통해 적절하게 적용되었으면 합니다 🤗

@ssi02014 ssi02014 assigned beberiche and unassigned ssi02014 Jul 5, 2024
@beberiche beberiche mentioned this issue Jul 6, 2024
3 tasks
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

Successfully merging a pull request may close this issue.

2 participants