forked from ramda/ramda
-
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.
- Loading branch information
1 parent
ddd9736
commit 246fbac
Showing
4 changed files
with
80 additions
and
1 deletion.
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,28 @@ | ||
import _curry1 from './internal/_curry1.js'; | ||
import isEmpty from './isEmpty.js'; | ||
|
||
|
||
/** | ||
* Returns `false` if the given value is its type's empty value; `true` | ||
* otherwise. | ||
* | ||
* @func | ||
* @memberOf R | ||
* @since v0.29.2 | ||
* @category Logic | ||
* @sig a -> Boolean | ||
* @param {*} x | ||
* @return {Boolean} | ||
* @see R.empty, R.isEmpty | ||
* @example | ||
* | ||
* R.isNotEmpty([1, 2, 3]); //=> true | ||
* R.isNotEmpty([]); //=> false | ||
* R.isNotEmpty(''); //=> false | ||
* R.isNotEmpty(null); //=> true | ||
* R.isNotEmpty({}); //=> false | ||
* R.isNotEmpty({length: 0}); //=> true | ||
* R.isNotEmpty(Uint8Array.from('')); //=> false | ||
*/ | ||
var isNotEmpty = _curry1(function isNotEmpty(x) { return !isEmpty(x); }); | ||
export default isNotEmpty; |
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,50 @@ | ||
var R = require('../source/index.js'); | ||
var eq = require('./shared/eq.js'); | ||
|
||
|
||
describe('isNotEmpty', function() { | ||
|
||
it('returns true for null', function() { | ||
eq(R.isNotEmpty(null), true); | ||
}); | ||
|
||
it('returns true for undefined', function() { | ||
eq(R.isNotEmpty(undefined), true); | ||
}); | ||
|
||
it('returns false for empty string', function() { | ||
eq(R.isNotEmpty(''), false); | ||
eq(R.isNotEmpty(' '), true); | ||
}); | ||
|
||
it('returns false for empty array', function() { | ||
eq(R.isNotEmpty([]), false); | ||
eq(R.isNotEmpty([[]]), true); | ||
}); | ||
|
||
it('returns false for empty typed array', function() { | ||
eq(R.isNotEmpty(Uint8Array.from('')), false); | ||
eq(R.isNotEmpty(Float32Array.from('')), false); | ||
eq(R.isNotEmpty(new Float32Array([])), false); | ||
eq(R.isNotEmpty(Uint8Array.from('1')), true); | ||
eq(R.isNotEmpty(Float32Array.from('1')), true); | ||
eq(R.isNotEmpty(new Float32Array([1])), true); | ||
}); | ||
|
||
it('returns false for empty object', function() { | ||
eq(R.isNotEmpty({}), false); | ||
eq(R.isNotEmpty({x: 0}), true); | ||
}); | ||
|
||
it('returns false for empty arguments object', function() { | ||
eq(R.isNotEmpty((function() { return arguments; })()), false); | ||
eq(R.isNotEmpty((function() { return arguments; })(0)), true); | ||
}); | ||
|
||
it('returns true for every other value', function() { | ||
eq(R.isNotEmpty(0), true); | ||
eq(R.isNotEmpty(NaN), true); | ||
eq(R.isNotEmpty(['']), true); | ||
}); | ||
|
||
}); |