-
-
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 isNonEmptyArray #289
Conversation
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.
Few things need to be addressed before merging. Nice job!
@@ -0,0 +1,23 @@ | |||
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.
insert one new empty line pls
|
||
import isNotEmpty from './isNotEmpty'; | ||
import isArray from './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.
insert one new empty line pls
/** | ||
* Checks if input value is a non empty `Array`. | ||
*/ | ||
isNonEmptyArray(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.
@char0n I think yes, there is no way we can express that array is non-empty in types
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.
Wouldn't be better to use boolean
instead ?
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.
when isNonEmptyArray
returns false
array methods still can be applied on name
so val is Array<any>
if fine )
src/isNonEmptyArray.js
Outdated
* RA.isNonEmptyArray(42); // => false | ||
* RA.isNonEmptyArray('42'); // => false | ||
*/ | ||
const isNonEmptyArray = both(isNotEmpty, 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 prefer one of the following compositions:
const isNonEmptyArray = both(isArray, isNotEmpty);
or
const isNonEmptyArray = both(isArray, complement(isEmptyArray));
according to char0n#279, checking if something is array is simpler then checking if an value is not empty.
63e1653
to
c83c16d
Compare
Ref #279