forked from char0n/ramda-adjunct
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ref char0n#279
- Loading branch information
Guillaume ARM
committed
Jan 18, 2018
1 parent
57b4de4
commit ed179f4
Showing
4 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { both } from 'ramda'; | ||
|
||
import isNotEmpty from './isNotEmpty'; | ||
import isArray from './isArray'; | ||
|
||
/** | ||
* Checks if input value is not an empty `Array`. | ||
* | ||
* @func isNonEmptyArray | ||
* @memberOf RA | ||
* @since {@link https://char0n.github.io/ramda-adjunct/2.4.0|v2.4.0} | ||
* @category Type | ||
* @sig * -> Boolean | ||
* @param {*} val The value to test | ||
* @return {Boolean} | ||
* @see {@link RA.isEmptyArray|isEmptyArray} | ||
* @example | ||
* | ||
* RA.isNonEmptyArray([42]); // => true | ||
* RA.isNonEmptyArray([]); // => false | ||
* RA.isNonEmptyArray({}); // => false | ||
* RA.isNonEmptyArray(null); // => false | ||
* RA.isNonEmptyArray(undefined); // => false | ||
* RA.isNonEmptyArray(42); // => false | ||
* RA.isNonEmptyArray('42'); // => false | ||
*/ | ||
const isNonEmptyArray = both(isNotEmpty, isArray); | ||
|
||
export default isNonEmptyArray; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import * as RA from '../src/index'; | ||
import eq from './shared/eq'; | ||
|
||
describe('isNonEmptyArray', function() { | ||
it('tests a value to be a non empty `Array`', function() { | ||
eq(RA.isNonEmptyArray([42]), true); | ||
eq(RA.isNonEmptyArray(new Array('content')), true); | ||
|
||
eq(RA.isNonEmptyArray([]), false); | ||
eq(RA.isNonEmptyArray(new Array()), false); | ||
eq(RA.isNonEmptyArray(new Array(42)), false); | ||
eq(RA.isNonEmptyArray(Array.prototype), false); | ||
eq(RA.isNonEmptyArray(void 0), false); | ||
eq(RA.isNonEmptyArray({}), false); | ||
eq(RA.isNonEmptyArray(null), false); | ||
eq(RA.isNonEmptyArray(undefined), false); | ||
eq(RA.isNonEmptyArray(42), false); | ||
eq(RA.isNonEmptyArray('Array'), false); | ||
eq(RA.isNonEmptyArray(true), false); | ||
eq(RA.isNonEmptyArray(false), false); | ||
eq(RA.isNonEmptyArray({ __proto__: Array.prototype }), false); | ||
}); | ||
}); |