-
-
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.
Closes #238
- Loading branch information
Showing
4 changed files
with
76 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,23 @@ | ||
import { propEq, complement, curryN } from 'ramda'; | ||
|
||
/** | ||
* Returns true if the specified object property is not equal, | ||
* in R.equals terms, to the given value; false otherwise. | ||
* | ||
* @func propNotEq | ||
* @memberOf RA | ||
* @since {@link https://char0n.github.io/ramda-adjunct/1.1.0|v1.1.0} | ||
* @category Relation | ||
* @sig String → a → Object → Boolean | ||
* @param {String} prop The prop to pick | ||
* @param {a} value The value to compare to | ||
* @param {Object} object The object, that presumably contains value under the prop | ||
* @return {Boolean} Comparison result | ||
* @see {@link http://ramdajs.com/docs/#propEq|propEq} | ||
* @example | ||
* | ||
* RA.propNotEq('Not you!', 'a', { a: 'foo', b: 'bar' }); //=> true | ||
*/ | ||
const propNotEq = curryN(3, complement(propEq)); | ||
|
||
export default propNotEq; |
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,41 @@ | ||
import * as RA from '../src/index'; | ||
import eq from './shared/eq'; | ||
|
||
|
||
describe('propNotEq', function() { | ||
let prop; | ||
let value; | ||
let obj; | ||
let expected; | ||
|
||
beforeEach(function() { | ||
prop = 'a'; | ||
value = 'foo'; | ||
obj = { a: 1, b: 2 }; | ||
expected = true; | ||
}); | ||
|
||
it('tests currying', function() { | ||
eq(RA.propNotEq(prop, value, obj), expected); | ||
eq(RA.propNotEq(prop)(value, obj), expected); | ||
eq(RA.propNotEq(prop, value)(obj), expected); | ||
eq(RA.propNotEq(prop)(value)(obj), expected); | ||
}); | ||
|
||
it('tests prop value is not equal', function() { | ||
eq(RA.propNotEq(prop, value, obj), expected); | ||
}); | ||
|
||
it('tests prop value is equal', function() { | ||
value = 1; | ||
expected = false; | ||
|
||
eq(RA.propNotEq(prop, value, obj), expected); | ||
}); | ||
|
||
it('tests no prop', function() { | ||
prop = 'bar'; | ||
|
||
eq(RA.propNotEq(prop, value, obj), expected); | ||
}); | ||
}); |