From 3f8cb6478cf58300984e8dd325f8c7a83e080f4a Mon Sep 17 00:00:00 2001 From: kedashoe Date: Sat, 13 May 2023 22:55:40 -0700 Subject: [PATCH] update swap and propEq --- docs/dist/ramda.js | 34 +++++++++++++++++++--------------- docs/index.html | 28 ++++++++++++++-------------- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/docs/dist/ramda.js b/docs/dist/ramda.js index f73a4fe..0725b14 100644 --- a/docs/dist/ramda.js +++ b/docs/dist/ramda.js @@ -1839,8 +1839,8 @@ * @see R.anyPass, R.both * @example * - * const isQueen = R.propEq('rank', 'Q'); - * const isSpade = R.propEq('suit', '♠︎'); + * const isQueen = R.propEq('Q', 'rank'); + * const isSpade = R.propEq('♠︎', 'suit'); * const isQueenOfSpades = R.allPass([isQueen, isSpade]); * * isQueenOfSpades({rank: 'Q', suit: '♣︎'}); //=> false @@ -2004,8 +2004,8 @@ * @see R.allPass, R.either * @example * - * const isClub = R.propEq('suit', '♣'); - * const isSpade = R.propEq('suit', '♠'); + * const isClub = R.propEq('♣', 'suit'); + * const isSpade = R.propEq('♠', 'suit'); * const isBlackCard = R.anyPass([isClub, isSpade]); * * isBlackCard({rank: '10', suit: '♣'}); //=> true @@ -5280,8 +5280,8 @@ * @example * * const xs = [{a: 1}, {a: 2}, {a: 3}]; - * R.find(R.propEq('a', 2))(xs); //=> {a: 2} - * R.find(R.propEq('a', 4))(xs); //=> undefined + * R.find(R.propEq(2, 'a'))(xs); //=> {a: 2} + * R.find(R.propEq(4, 'a'))(xs); //=> undefined */ var find = _curry2(_dispatchable(['find'], _xfind, function find(fn, list) { @@ -5350,8 +5350,8 @@ * @example * * const xs = [{a: 1}, {a: 2}, {a: 3}]; - * R.findIndex(R.propEq('a', 2))(xs); //=> 1 - * R.findIndex(R.propEq('a', 4))(xs); //=> -1 + * R.findIndex(R.propEq(2, 'a'))(xs); //=> 1 + * R.findIndex(R.propEq(4, 'a'))(xs); //=> -1 */ var findIndex = _curry2(_dispatchable([], _xfindIndex, function findIndex(fn, list) { @@ -5413,8 +5413,8 @@ * @example * * const xs = [{a: 1, b: 0}, {a:1, b: 1}]; - * R.findLast(R.propEq('a', 1))(xs); //=> {a: 1, b: 1} - * R.findLast(R.propEq('a', 4))(xs); //=> undefined + * R.findLast(R.propEq(1, 'a'))(xs); //=> {a: 1, b: 1} + * R.findLast(R.propEq(4, 'a'))(xs); //=> undefined */ var findLast = _curry2(_dispatchable([], _xfindLast, function findLast(fn, list) { @@ -5477,8 +5477,8 @@ * @example * * const xs = [{a: 1, b: 0}, {a:1, b: 1}]; - * R.findLastIndex(R.propEq('a', 1))(xs); //=> 1 - * R.findLastIndex(R.propEq('a', 4))(xs); //=> -1 + * R.findLastIndex(R.propEq(1, 'a'))(xs); //=> 1 + * R.findLastIndex(R.propEq(4, 'a'))(xs); //=> -1 */ var findLastIndex = _curry2(_dispatchable([], _xfindLastIndex, function findLastIndex(fn, list) { @@ -7900,10 +7900,14 @@ */ var modifyPath = _curry3(function modifyPath(path, fn, object) { - if (!_isObject(object) && !_isArray(object) || path.length === 0) { + if (!_isObject(object) && !_isArray(object)) { return object; } + if (path.length === 0) { + return fn(object); + } + var idx = path[0]; if (!_has(idx, object)) { @@ -9762,8 +9766,8 @@ * @example * * R.swap(0, 2, ['a', 'b', 'c', 'd', 'e', 'f']); //=> ['c', 'b', 'a', 'd', 'e', 'f'] - * R.swap(-1, 0, ['a', 'b', 'c', 'd', 'e', 'f']); //=> ['f', 'b', 'c', 'd', 'e', 'a'] list rotation - * R.swap('a', 'b', {a: 1, b: 2}); //=> {a: 2, b: 2} + * R.swap(-1, 0, ['a', 'b', 'c', 'd', 'e', 'f']); //=> ['f', 'b', 'c', 'd', 'e', 'a'] + * R.swap('a', 'b', {a: 1, b: 2}); //=> {a: 2, b: 1} * R.swap(0, 2, 'foo'); //=> 'oof' */ diff --git a/docs/index.html b/docs/index.html index 08f8b90..c2d5cae 100644 --- a/docs/index.html +++ b/docs/index.html @@ -2279,8 +2279,8 @@

both. -
const isQueen = R.propEq('rank', 'Q'); -const isSpade = R.propEq('suit', '♠︎'); +
const isQueen = R.propEq('Q', 'rank'); +const isSpade = R.propEq('♠︎', 'suit'); const isQueenOfSpades = R.allPass([isQueen, isSpade]); isQueenOfSpades({rank: 'Q', suit: '♣︎'}); //=> false @@ -2575,8 +2575,8 @@

either. -
const isClub = R.propEq('suit', '♣'); -const isSpade = R.propEq('suit', '♠'); +
const isClub = R.propEq('♣', 'suit'); +const isSpade = R.propEq('♠', 'suit'); const isBlackCard = R.anyPass([isClub, isSpade]); isBlackCard({rank: '10', suit: '♣'}); //=> true @@ -5977,8 +5977,8 @@

const xs = [{a: 1}, {a: 2}, {a: 3}]; -R.find(R.propEq('a', 2))(xs); //=> {a: 2} -R.find(R.propEq('a', 4))(xs); //=> undefined
+R.find(R.propEq(2, 'a'))(xs); //=> {a: 2} +R.find(R.propEq(4, 'a'))(xs); //=> undefined

@@ -6038,8 +6038,8 @@

const xs = [{a: 1}, {a: 2}, {a: 3}]; -R.findIndex(R.propEq('a', 2))(xs); //=> 1 -R.findIndex(R.propEq('a', 4))(xs); //=> -1
+R.findIndex(R.propEq(2, 'a'))(xs); //=> 1 +R.findIndex(R.propEq(4, 'a'))(xs); //=> -1

@@ -6098,8 +6098,8 @@

const xs = [{a: 1, b: 0}, {a:1, b: 1}]; -R.findLast(R.propEq('a', 1))(xs); //=> {a: 1, b: 1} -R.findLast(R.propEq('a', 4))(xs); //=> undefined
+R.findLast(R.propEq(1, 'a'))(xs); //=> {a: 1, b: 1} +R.findLast(R.propEq(4, 'a'))(xs); //=> undefined

@@ -6159,8 +6159,8 @@

const xs = [{a: 1, b: 0}, {a:1, b: 1}]; -R.findLastIndex(R.propEq('a', 1))(xs); //=> 1 -R.findLastIndex(R.propEq('a', 4))(xs); //=> -1
+R.findLastIndex(R.propEq(1, 'a'))(xs); //=> 1 +R.findLastIndex(R.propEq(4, 'a'))(xs); //=> -1

@@ -14953,8 +14953,8 @@

R.swap(0, 2, ['a', 'b', 'c', 'd', 'e', 'f']); //=> ['c', 'b', 'a', 'd', 'e', 'f'] -R.swap(-1, 0, ['a', 'b', 'c', 'd', 'e', 'f']); //=> ['f', 'b', 'c', 'd', 'e', 'a'] list rotation -R.swap('a', 'b', {a: 1, b: 2}); //=> {a: 2, b: 2} +R.swap(-1, 0, ['a', 'b', 'c', 'd', 'e', 'f']); //=> ['f', 'b', 'c', 'd', 'e', 'a'] +R.swap('a', 'b', {a: 1, b: 2}); //=> {a: 2, b: 1} R.swap(0, 2, 'foo'); //=> 'oof'