[d24f17c] | 1 | import { pathEq, complement } from 'ramda';
|
---|
| 2 |
|
---|
| 3 | /* eslint-disable max-len */
|
---|
| 4 | /**
|
---|
| 5 | * Determines whether a nested path on an object doesn't have a specific value,
|
---|
| 6 | * in R.equals terms. Most likely used to filter a list.
|
---|
| 7 | *
|
---|
| 8 | * @func pathNotEq
|
---|
| 9 | * @memberOf RA
|
---|
| 10 | * @since {@link https://char0n.github.io/ramda-adjunct/2.4.0|v2.4.0}
|
---|
| 11 | * @category Relation
|
---|
| 12 | * @sig a => [Idx] => {a} => Boolean
|
---|
| 13 | * @sig Idx = String | Int | Symbol
|
---|
| 14 | * @param {a} val The value to compare the nested property with
|
---|
| 15 | * @param {Array} path The path of the nested property to use
|
---|
| 16 | * @param {Object} object The object to check the nested property in
|
---|
| 17 | * @return {boolean} Returns Boolean `false` if the value equals the nested object property, `true` otherwise
|
---|
| 18 | * @see {@link http://ramdajs.com/docs/#pathEq|R.pathEq}
|
---|
| 19 | * @example
|
---|
| 20 | *
|
---|
| 21 | * const user1 = { address: { zipCode: 90210 } };
|
---|
| 22 | * const user2 = { address: { zipCode: 55555 } };
|
---|
| 23 | * const user3 = { name: 'Bob' };
|
---|
| 24 | * const users = [ user1, user2, user3 ];
|
---|
| 25 | * const isFamous = RA.pathNotEq(90210, ['address', 'zipCode']);
|
---|
| 26 | * R.filter(isFamous, users); //=> [ user2, user3 ]
|
---|
| 27 | */
|
---|
| 28 | /* eslint-enable max-len */
|
---|
| 29 | const pathNotEq = complement(pathEq);
|
---|
| 30 |
|
---|
| 31 | export default pathNotEq;
|
---|