Skip to content

Commit

Permalink
update swap and propEq
Browse files Browse the repository at this point in the history
  • Loading branch information
kedashoe committed May 14, 2023
1 parent c796454 commit 3f8cb64
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 29 deletions.
34 changes: 19 additions & 15 deletions docs/dist/ramda.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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'
*/

Expand Down
28 changes: 14 additions & 14 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2279,8 +2279,8 @@ <h2>
<a href="#both">both</a>.
</div>

<pre><div class = "try-repl" ><button class = "send-repl" data-ramda-version="0.29.0">Open in REPL</button><button class = "run-here" data-ramda-version="0.29.0">Run it here</button></div><code class="hljs javascript"><span class="hljs-keyword">const</span> isQueen = R.propEq(<span class="hljs-string">&#x27;rank&#x27;</span>, <span class="hljs-string">&#x27;Q&#x27;</span>);
<span class="hljs-keyword">const</span> isSpade = R.propEq(<span class="hljs-string">&#x27;suit&#x27;</span>, <span class="hljs-string">&#x27;♠︎&#x27;</span>);
<pre><div class = "try-repl" ><button class = "send-repl" data-ramda-version="0.29.0">Open in REPL</button><button class = "run-here" data-ramda-version="0.29.0">Run it here</button></div><code class="hljs javascript"><span class="hljs-keyword">const</span> isQueen = R.propEq(<span class="hljs-string">&#x27;Q&#x27;</span>, <span class="hljs-string">&#x27;rank&#x27;</span>);
<span class="hljs-keyword">const</span> isSpade = R.propEq(<span class="hljs-string">&#x27;♠︎&#x27;</span>, <span class="hljs-string">&#x27;suit&#x27;</span>);
<span class="hljs-keyword">const</span> isQueenOfSpades = R.allPass([isQueen, isSpade]);

isQueenOfSpades({<span class="hljs-attr">rank</span>: <span class="hljs-string">&#x27;Q&#x27;</span>, <span class="hljs-attr">suit</span>: <span class="hljs-string">&#x27;♣︎&#x27;</span>}); <span class="hljs-comment">//=&gt; false</span>
Expand Down Expand Up @@ -2575,8 +2575,8 @@ <h2>
<a href="#either">either</a>.
</div>

<pre><div class = "try-repl" ><button class = "send-repl" data-ramda-version="0.29.0">Open in REPL</button><button class = "run-here" data-ramda-version="0.29.0">Run it here</button></div><code class="hljs javascript"><span class="hljs-keyword">const</span> isClub = R.propEq(<span class="hljs-string">&#x27;suit&#x27;</span>, <span class="hljs-string">&#x27;&#x27;</span>);
<span class="hljs-keyword">const</span> isSpade = R.propEq(<span class="hljs-string">&#x27;suit&#x27;</span>, <span class="hljs-string">&#x27;&#x27;</span>);
<pre><div class = "try-repl" ><button class = "send-repl" data-ramda-version="0.29.0">Open in REPL</button><button class = "run-here" data-ramda-version="0.29.0">Run it here</button></div><code class="hljs javascript"><span class="hljs-keyword">const</span> isClub = R.propEq(<span class="hljs-string">&#x27;&#x27;</span>, <span class="hljs-string">&#x27;suit&#x27;</span>);
<span class="hljs-keyword">const</span> isSpade = R.propEq(<span class="hljs-string">&#x27;&#x27;</span>, <span class="hljs-string">&#x27;suit&#x27;</span>);
<span class="hljs-keyword">const</span> isBlackCard = R.anyPass([isClub, isSpade]);

isBlackCard({<span class="hljs-attr">rank</span>: <span class="hljs-string">&#x27;10&#x27;</span>, <span class="hljs-attr">suit</span>: <span class="hljs-string">&#x27;♣&#x27;</span>}); <span class="hljs-comment">//=&gt; true</span>
Expand Down Expand Up @@ -5977,8 +5977,8 @@ <h2>
</div>

<pre><div class = "try-repl" ><button class = "send-repl" data-ramda-version="0.29.0">Open in REPL</button><button class = "run-here" data-ramda-version="0.29.0">Run it here</button></div><code class="hljs javascript"><span class="hljs-keyword">const</span> xs = [{<span class="hljs-attr">a</span>: <span class="hljs-number">1</span>}, {<span class="hljs-attr">a</span>: <span class="hljs-number">2</span>}, {<span class="hljs-attr">a</span>: <span class="hljs-number">3</span>}];
R.find(R.propEq(<span class="hljs-string">&#x27;a&#x27;</span>, <span class="hljs-number">2</span>))(xs); <span class="hljs-comment">//=&gt; {a: 2}</span>
R.find(R.propEq(<span class="hljs-string">&#x27;a&#x27;</span>, <span class="hljs-number">4</span>))(xs); <span class="hljs-comment">//=&gt; undefined</span></code></pre>
R.find(R.propEq(<span class="hljs-number">2</span>, <span class="hljs-string">&#x27;a&#x27;</span>))(xs); <span class="hljs-comment">//=&gt; {a: 2}</span>
R.find(R.propEq(<span class="hljs-number">4</span>, <span class="hljs-string">&#x27;a&#x27;</span>))(xs); <span class="hljs-comment">//=&gt; undefined</span></code></pre>
</section>
<div id="findIndex" class="section-id"></div>
<section class="card">
Expand Down Expand Up @@ -6038,8 +6038,8 @@ <h2>
</div>

<pre><div class = "try-repl" ><button class = "send-repl" data-ramda-version="0.29.0">Open in REPL</button><button class = "run-here" data-ramda-version="0.29.0">Run it here</button></div><code class="hljs javascript"><span class="hljs-keyword">const</span> xs = [{<span class="hljs-attr">a</span>: <span class="hljs-number">1</span>}, {<span class="hljs-attr">a</span>: <span class="hljs-number">2</span>}, {<span class="hljs-attr">a</span>: <span class="hljs-number">3</span>}];
R.findIndex(R.propEq(<span class="hljs-string">&#x27;a&#x27;</span>, <span class="hljs-number">2</span>))(xs); <span class="hljs-comment">//=&gt; 1</span>
R.findIndex(R.propEq(<span class="hljs-string">&#x27;a&#x27;</span>, <span class="hljs-number">4</span>))(xs); <span class="hljs-comment">//=&gt; -1</span></code></pre>
R.findIndex(R.propEq(<span class="hljs-number">2</span>, <span class="hljs-string">&#x27;a&#x27;</span>))(xs); <span class="hljs-comment">//=&gt; 1</span>
R.findIndex(R.propEq(<span class="hljs-number">4</span>, <span class="hljs-string">&#x27;a&#x27;</span>))(xs); <span class="hljs-comment">//=&gt; -1</span></code></pre>
</section>
<div id="findLast" class="section-id"></div>
<section class="card">
Expand Down Expand Up @@ -6098,8 +6098,8 @@ <h2>
</div>

<pre><div class = "try-repl" ><button class = "send-repl" data-ramda-version="0.29.0">Open in REPL</button><button class = "run-here" data-ramda-version="0.29.0">Run it here</button></div><code class="hljs javascript"><span class="hljs-keyword">const</span> xs = [{<span class="hljs-attr">a</span>: <span class="hljs-number">1</span>, <span class="hljs-attr">b</span>: <span class="hljs-number">0</span>}, {<span class="hljs-attr">a</span>:<span class="hljs-number">1</span>, <span class="hljs-attr">b</span>: <span class="hljs-number">1</span>}];
R.findLast(R.propEq(<span class="hljs-string">&#x27;a&#x27;</span>, <span class="hljs-number">1</span>))(xs); <span class="hljs-comment">//=&gt; {a: 1, b: 1}</span>
R.findLast(R.propEq(<span class="hljs-string">&#x27;a&#x27;</span>, <span class="hljs-number">4</span>))(xs); <span class="hljs-comment">//=&gt; undefined</span></code></pre>
R.findLast(R.propEq(<span class="hljs-number">1</span>, <span class="hljs-string">&#x27;a&#x27;</span>))(xs); <span class="hljs-comment">//=&gt; {a: 1, b: 1}</span>
R.findLast(R.propEq(<span class="hljs-number">4</span>, <span class="hljs-string">&#x27;a&#x27;</span>))(xs); <span class="hljs-comment">//=&gt; undefined</span></code></pre>
</section>
<div id="findLastIndex" class="section-id"></div>
<section class="card">
Expand Down Expand Up @@ -6159,8 +6159,8 @@ <h2>
</div>

<pre><div class = "try-repl" ><button class = "send-repl" data-ramda-version="0.29.0">Open in REPL</button><button class = "run-here" data-ramda-version="0.29.0">Run it here</button></div><code class="hljs javascript"><span class="hljs-keyword">const</span> xs = [{<span class="hljs-attr">a</span>: <span class="hljs-number">1</span>, <span class="hljs-attr">b</span>: <span class="hljs-number">0</span>}, {<span class="hljs-attr">a</span>:<span class="hljs-number">1</span>, <span class="hljs-attr">b</span>: <span class="hljs-number">1</span>}];
R.findLastIndex(R.propEq(<span class="hljs-string">&#x27;a&#x27;</span>, <span class="hljs-number">1</span>))(xs); <span class="hljs-comment">//=&gt; 1</span>
R.findLastIndex(R.propEq(<span class="hljs-string">&#x27;a&#x27;</span>, <span class="hljs-number">4</span>))(xs); <span class="hljs-comment">//=&gt; -1</span></code></pre>
R.findLastIndex(R.propEq(<span class="hljs-number">1</span>, <span class="hljs-string">&#x27;a&#x27;</span>))(xs); <span class="hljs-comment">//=&gt; 1</span>
R.findLastIndex(R.propEq(<span class="hljs-number">4</span>, <span class="hljs-string">&#x27;a&#x27;</span>))(xs); <span class="hljs-comment">//=&gt; -1</span></code></pre>
</section>
<div id="flatten" class="section-id"></div>
<section class="card">
Expand Down Expand Up @@ -14953,8 +14953,8 @@ <h2>


<pre><div class = "try-repl" ><button class = "send-repl" data-ramda-version="0.29.0">Open in REPL</button><button class = "run-here" data-ramda-version="0.29.0">Run it here</button></div><code class="hljs javascript">R.swap(<span class="hljs-number">0</span>, <span class="hljs-number">2</span>, [<span class="hljs-string">&#x27;a&#x27;</span>, <span class="hljs-string">&#x27;b&#x27;</span>, <span class="hljs-string">&#x27;c&#x27;</span>, <span class="hljs-string">&#x27;d&#x27;</span>, <span class="hljs-string">&#x27;e&#x27;</span>, <span class="hljs-string">&#x27;f&#x27;</span>]); <span class="hljs-comment">//=&gt; [&#x27;c&#x27;, &#x27;b&#x27;, &#x27;a&#x27;, &#x27;d&#x27;, &#x27;e&#x27;, &#x27;f&#x27;]</span>
R.swap(-<span class="hljs-number">1</span>, <span class="hljs-number">0</span>, [<span class="hljs-string">&#x27;a&#x27;</span>, <span class="hljs-string">&#x27;b&#x27;</span>, <span class="hljs-string">&#x27;c&#x27;</span>, <span class="hljs-string">&#x27;d&#x27;</span>, <span class="hljs-string">&#x27;e&#x27;</span>, <span class="hljs-string">&#x27;f&#x27;</span>]); <span class="hljs-comment">//=&gt; [&#x27;f&#x27;, &#x27;b&#x27;, &#x27;c&#x27;, &#x27;d&#x27;, &#x27;e&#x27;, &#x27;a&#x27;] list rotation</span>
R.swap(<span class="hljs-string">&#x27;a&#x27;</span>, <span class="hljs-string">&#x27;b&#x27;</span>, {<span class="hljs-attr">a</span>: <span class="hljs-number">1</span>, <span class="hljs-attr">b</span>: <span class="hljs-number">2</span>}); <span class="hljs-comment">//=&gt; {a: 2, b: 2}</span>
R.swap(-<span class="hljs-number">1</span>, <span class="hljs-number">0</span>, [<span class="hljs-string">&#x27;a&#x27;</span>, <span class="hljs-string">&#x27;b&#x27;</span>, <span class="hljs-string">&#x27;c&#x27;</span>, <span class="hljs-string">&#x27;d&#x27;</span>, <span class="hljs-string">&#x27;e&#x27;</span>, <span class="hljs-string">&#x27;f&#x27;</span>]); <span class="hljs-comment">//=&gt; [&#x27;f&#x27;, &#x27;b&#x27;, &#x27;c&#x27;, &#x27;d&#x27;, &#x27;e&#x27;, &#x27;a&#x27;]</span>
R.swap(<span class="hljs-string">&#x27;a&#x27;</span>, <span class="hljs-string">&#x27;b&#x27;</span>, {<span class="hljs-attr">a</span>: <span class="hljs-number">1</span>, <span class="hljs-attr">b</span>: <span class="hljs-number">2</span>}); <span class="hljs-comment">//=&gt; {a: 2, b: 1}</span>
R.swap(<span class="hljs-number">0</span>, <span class="hljs-number">2</span>, <span class="hljs-string">&#x27;foo&#x27;</span>); <span class="hljs-comment">//=&gt; &#x27;oof&#x27;</span></code></pre>
</section>
<div id="symmetricDifference" class="section-id"></div>
Expand Down

0 comments on commit 3f8cb64

Please sign in to comment.