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

What's the difference between A.all and A.every, A.any and A.some? #118

Open
ThatsEmbarrassing opened this issue Oct 5, 2024 · 0 comments

Comments

@ThatsEmbarrassing
Copy link

According to the documentation, there are four functions to check if the whole array or at least one element of it satisfies the condition.

However, I don't see the difference between them, because they act the same.

// A.all / A.every

console.log(A.all([2, 4, 6, 8, 10], (value) => value % 2 === 0)); // true
console.log(A.every([2, 4, 6, 8, 10], (value) => value % 2 === 0)); // true

console.log(A.all([1, 4, 5, 7, 9], (value) => value % 2 === 0)); // false
console.log(A.every([1, 4, 5, 7, 9], (value) => value % 2 === 0)); // false

console.log(A.all([1, 3, 5, 7, 9], (value) => value % 2 === 0)); // false
console.log(A.every([1, 3, 5, 7, 9], (value) => value % 2 === 0)); // false
// A.any / A.some

console.log(A.any([2, 4, 6, 8, 10], (value) => value % 2 === 0)); // true
console.log(A.some([2, 4, 6, 8, 10], (value) => value % 2 === 0)); // true

console.log(A.any([1, 4, 5, 7, 9], (value) => value % 2 === 0)); // true
console.log(A.some([1, 4, 5, 7, 9], (value) => value % 2 === 0)); // true

console.log(A.any([1, 3, 5, 7, 9], (value) => value % 2 === 0)); // false
console.log(A.some([1, 3, 5, 7, 9], (value) => value % 2 === 0)); // false

It's not said if the one function of them is an alias for another and their declarations are a bit only different. So I find it confusing for developers using this library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant