-
-
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.
Ref #66
- Loading branch information
Showing
5 changed files
with
68 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,29 @@ | ||
import { complement } from 'ramda'; | ||
|
||
import isTruthy from './isTruthy'; | ||
|
||
|
||
/** | ||
* A falsy value is a value that translates to false when evaluated in a Boolean context. | ||
* Falsy values are `false`, `0`, `""`, `null`, `undefined`, and `NaN`. | ||
* | ||
* @func isFalsy | ||
* @memberOf RA | ||
* @since {@link https://char0n.github.io/ramda-adjunct/2.2.0|v2.2..0} | ||
* @category Type | ||
* @sig * -> Boolean | ||
* @param {*} val The value to test | ||
* @return {Boolean} | ||
* @see {@link https://developer.mozilla.org/en-US/docs/Glossary/Falsy|falsy}, {@link RA.isTruthy|isTruthy} | ||
* @example | ||
* | ||
* RA.isFalsy(false); // => true | ||
* RA.isFalsy(0); // => true | ||
* RA.isFalsy(''); // => true | ||
* RA.isFalsy(null); // => true | ||
* RA.isFalsy(undefined); // => true | ||
* RA.isFalsy(NaN); // => true | ||
*/ | ||
const isFalsy = complement(isTruthy); | ||
|
||
export default isFalsy; |
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,31 @@ | ||
import * as RA from '../src/index'; | ||
import eq from './shared/eq'; | ||
import Symbol from './shared/Symbol'; | ||
import args from './shared/arguments'; | ||
|
||
|
||
describe('isFalsy', function() { | ||
it('tests a value for `falsy`', function() { | ||
eq(RA.isFalsy(false), true); | ||
eq(RA.isFalsy(0), true); | ||
eq(RA.isFalsy(''), true); | ||
eq(RA.isFalsy(null), true); | ||
eq(RA.isFalsy(undefined), true); | ||
eq(RA.isFalsy(NaN), true); | ||
|
||
eq(RA.isFalsy('abc'), false); | ||
eq(RA.isFalsy(Object('abc')), false); | ||
eq(RA.isFalsy(args), false); | ||
eq(RA.isFalsy([1, 2, 3]), false); | ||
eq(RA.isFalsy(new Date()), false); | ||
eq(RA.isFalsy(new Error()), false); | ||
eq(RA.isFalsy(Array.prototype.slice), false); | ||
eq(RA.isFalsy({ 0: 1, length: 1 }), false); | ||
eq(RA.isFalsy(1), false); | ||
eq(RA.isFalsy(/x/), false); | ||
eq(RA.isFalsy(Symbol), RA.isUndefined(Symbol)); | ||
eq(RA.isFalsy({}), false); | ||
eq(RA.isFalsy([]), false); | ||
eq(RA.isFalsy(Infinity), false); | ||
}); | ||
}); |