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

feat: add isNonEmptyArray #289

Merged
merged 3 commits into from
Jan 19, 2018
Merged

Conversation

guillaumearm
Copy link
Collaborator

Ref #279

Copy link
Owner

@char0n char0n left a 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';

Copy link
Owner

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';

Copy link
Owner

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>;
Copy link
Owner

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 ?

Copy link
Collaborator

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

Copy link
Owner

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 ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* RA.isNonEmptyArray(42); // => false
* RA.isNonEmptyArray('42'); // => false
*/
const isNonEmptyArray = both(isNotEmpty, isArray);
Copy link
Owner

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)); 

@srghma srghma mentioned this pull request Jan 18, 2018
Guillaume ARM added 2 commits January 18, 2018 16:49
according to char0n#279, checking if something is array is simpler then checking if an value is not empty.
@char0n char0n merged commit 464060e into char0n:master Jan 19, 2018
@guillaumearm guillaumearm deleted the feat/isNonEmptyArray branch January 19, 2018 19:43
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

Successfully merging this pull request may close these issues.

3 participants