-
-
Notifications
You must be signed in to change notification settings - Fork 87
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
feat: add isEmptyArray #288
Conversation
@char0n : any suggestions ? |
Will get to this in a couple of hours. Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clean and nice. Couple of issue need to be addressed before merging. Nice job!
/** | ||
* Checks if input value is an empty `Array`. | ||
*/ | ||
isEmptyArray(val: any): val is Array<any>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BjornMelgaard I'm not sure about this. Can you advice ? Does this signature make sense in the context of empty array ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as here #289 (comment)
@@ -0,0 +1,21 @@ | |||
import * as RA from '../src/index'; | |||
import eq from './shared/eq'; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add one more new line pls
src/isEmptyArray.js
Outdated
* RA.isEmptyArray(42); // => false | ||
* RA.isEmptyArray('42'); // => false | ||
*/ | ||
const isEmptyArray = both(isEmpty, isArray); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd go for a following composition. It may same same computing time. Checking if something is array is simpler then checking if an value is empty.
const isEmptyArray = both(isArray, isEmpty);
* @func isEmptyArray | ||
* @memberOf RA | ||
* @since {@link https://char0n.github.io/ramda-adjunct/2.4.0|v2.4.0} | ||
* @category Type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking if this still falls into Type
category or is already an Logic
. @guillaumearm what's your opinion on this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be using logic under the hood, but its API and usage put it in Type imho.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, it's a mix of both : Type and Logic
Because an empty array and a non empty array have the same type, it's a very good question to ask.
Is it ok to passing same type to a Type
function produce a different result ?
on another side RA.isNotEmpty
should be in Logic
category like R.isEmpty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for creating the issue for it. I’ll handle that. Regarding the question whether this is type or logic... I would say we are still in type world. If we look at it throug the lens of category theory let us say we have two new types EmptyArray and NonEmptyArray. Assuming this we cas say that our two new type functions are just checking out the correct types. Logic of the checking becomes only the implementation detail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems correct, Agree ^^
Pls rebase this pr on top of current master also |
Should I --amend my |
No need to, you have to rebase your branch |
No no i'm ok with that ;-) thanks |
according to char0n#279, checking if something is array is simpler then checking if an value is empty.
a4701a5
to
ce7f63d
Compare
Ref #279