-
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
59 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(isArray, isNotEmpty); | ||
|
||
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,24 @@ | ||
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); | ||
}); | ||
}); |