Skip to content

Commit

Permalink
prepare
Browse files Browse the repository at this point in the history
  • Loading branch information
selfrefactor committed Nov 5, 2024
1 parent d8b9346 commit faddaea
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 28 deletions.
21 changes: 18 additions & 3 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6454,10 +6454,9 @@ function ifElseFn(
condition, onTrue, onFalse
){
return (...input) => {
const conditionResult =
const conditionResult =
typeof condition === 'boolean' ? condition : condition(...input)

if (conditionResult === true){
if (Boolean(conditionResult) ){
return onTrue(...input)
}

Expand All @@ -6480,6 +6479,7 @@ import { has } from './has.js'
import { identity } from './identity.js'
import { ifElse } from './ifElse.js'
import { prop } from './prop.js'
import * as R from 'ramda'

const condition = has('foo')
const v = function (a){
Expand Down Expand Up @@ -6567,6 +6567,17 @@ test('simple arity of 2', () => {
)(1, 10)
expect(result).toBe(12)
})

test('bug 750', () => {
const value = 34;

let result = ifElse(
R.identity,
R.always('true'),
R.always('false')
)(value)
expect(result).toBe('true')
})
```

</details>
Expand Down Expand Up @@ -18587,6 +18598,10 @@ describe('R.zipWith', () => {

- Fix `deno` release

- Fix too strict `true` condition in `R.ifElse` - [Issue #750](https://github.com/selfrefactor/rambda/issues/750)

- Change `R.groupBy` typings to match `@types/ramda` typings

9.3.0

- Breaking change in relation to TS typings of `R.assoc`, `R.dissoc` and `R.modify` - https://github.com/ramda/types/pull/37
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

- Fix `deno` release

- Fix too strict `true` condition in `R.ifElse` - [Issue #750](https://github.com/selfrefactor/rambda/issues/750)

- Change `R.groupBy` typings to match `@types/ramda` typings

9.3.0

- Breaking change in relation to TS typings of `R.assoc`, `R.dissoc` and `R.modify` - https://github.com/ramda/types/pull/37
Expand Down
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6084,10 +6084,9 @@ function ifElseFn(
condition, onTrue, onFalse
){
return (...input) => {
const conditionResult =
const conditionResult =
typeof condition === 'boolean' ? condition : condition(...input)

if (conditionResult === true){
if (Boolean(conditionResult) ){
return onTrue(...input)
}

Expand All @@ -6110,6 +6109,7 @@ import { has } from './has.js'
import { identity } from './identity.js'
import { ifElse } from './ifElse.js'
import { prop } from './prop.js'
import * as R from 'ramda'

const condition = has('foo')
const v = function (a){
Expand Down Expand Up @@ -6197,6 +6197,17 @@ test('simple arity of 2', () => {
)(1, 10)
expect(result).toBe(12)
})

test('bug 750', () => {
const value = 34;

let result = ifElse(
R.identity,
R.always('true'),
R.always('false')
)(value)
expect(result).toBe('true')
})
```

</details>
Expand Down Expand Up @@ -17277,6 +17288,10 @@ describe('R.zipWith', () => {

- Fix `deno` release

- Fix too strict `true` condition in `R.ifElse` - [Issue #750](https://github.com/selfrefactor/rambda/issues/750)

- Change `R.groupBy` typings to match `@types/ramda` typings

9.3.0

- Breaking change in relation to TS typings of `R.assoc`, `R.dissoc` and `R.modify` - https://github.com/ramda/types/pull/37
Expand Down
2 changes: 1 addition & 1 deletion dist/rambda.js
Original file line number Diff line number Diff line change
Expand Up @@ -1404,7 +1404,7 @@ function identical(a, b) {
function ifElseFn(condition, onTrue, onFalse) {
return (...input) => {
const conditionResult = typeof condition === 'boolean' ? condition : condition(...input);
if (conditionResult === true) {
if (Boolean(conditionResult)) {
return onTrue(...input);
}
return onFalse(...input);
Expand Down
2 changes: 1 addition & 1 deletion dist/rambda.umd.js

Large diffs are not rendered by default.

58 changes: 43 additions & 15 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

`Rambda` is smaller and faster alternative to the popular functional programming library **Ramda**. - [Documentation](https://selfrefactor.github.io/rambda/#/)

[![CircleCI](https://circleci.com/gh/selfrefactor/rambda/tree/master.svg?style=svg)](https://circleci.com/gh/selfrefactor/rambda/tree/master)
[![codecov](https://codecov.io/gh/selfrefactor/rambda/branch/master/graph/badge.svg)](https://codecov.io/gh/selfrefactor/rambda)
![Commit activity](https://img.shields.io/github/commit-activity/y/selfrefactor/rambda)
![All contributors](https://img.shields.io/github/contributors/selfrefactor/rambda)
![Library size](https://img.shields.io/bundlephobia/minzip/rambda)
[![install size](https://packagephobia.com/badge?p=rambda)](https://packagephobia.com/result?p=rambda)
[![nest badge](https://nest.land/badge.svg)](https://nest.land/package/rambda)
[![PR's Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)](https://github.com/selfrefactor/rambda/pulls)
[![GitHub contributors](https://img.shields.io/github/contributors/selfrefactor/rambda.svg)](https://github.com/selfrefactor/rambda/graphs/contributors)

## ❯ Example use

Expand Down Expand Up @@ -1770,7 +1768,7 @@ describe('applySpec', () => {

### ascend

<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.sort(%0A%20%20R.ascend(x%20%3D%3E%20x)%2C%0A%20%20%5B2%2C%201%5D%0A)%0A%2F%2F%20%3D%3E%20%5B1%2C%202%5D">Try this <strong>R.ascend</strong> example in Rambda REPL</a>
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.sort(R.descend(x%20%3D%3E%20x)%2C%20%5B2%2C%201%5D)%0A%2F%2F%20%3D%3E%20%5B1%2C%202%5D">Try this <strong>R.ascend</strong> example in Rambda REPL</a>

[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#ascend)

Expand Down Expand Up @@ -1867,7 +1865,7 @@ export const assocPath = curry(assocPathFn)
```javascript
import { assocPathFn } from './assocPath.js'

test.only('happy', () => {
test('happy', () => {
const path = 'a.c.1'
const input = {
a : {
Expand Down Expand Up @@ -1908,7 +1906,7 @@ test('string can be used as path input', () => {

test('difference with ramda - doesn\'t overwrite primitive values with keys in the path', () => {
const obj = { a : 'str' }
const result = assocPath(
const result = assocPathFn(
[ 'a', 'b' ], 42, obj
)

Expand All @@ -1922,7 +1920,18 @@ test('difference with ramda - doesn\'t overwrite primitive values with keys in t
})
})

test('bug', () => {
test('bug 748', () => {
/*
https://github.com/selfrefactor/rambda/issues/748
*/
const obj = {};
let result = assocPathFn(['a', '2'], 3, obj)
let result1 = assocPath(['a', '2'], 3, obj)
console.log({result})
console.log(result1)
})

test('bug 524', () => {
/*
https://github.com/selfrefactor/rambda/issues/524
*/
Expand Down Expand Up @@ -2886,7 +2895,7 @@ describe('R.defaultTo with Ramda spec', () => {

### descend

<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.sort(%0A%20%20R.descend(x%20%3D>%20x)%2C%0A%20%20%5B1%2C%202%5D%0A)%0A%2F%2F%20%3D>%20%5B2%2C%201%5D">Try this <strong>R.descend</strong> example in Rambda REPL</a>
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20result%20%3D%20R.sort(R.descend(x%20%3D%3E%20x)%2C%20%5B1%2C%202%5D)%0A%2F%2F%20%3D%3E%20%5B2%2C%201%5D">Try this <strong>R.descend</strong> example in Rambda REPL</a>

[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#descend)

Expand Down Expand Up @@ -5633,7 +5642,7 @@ It splits `list` according to a provided `groupFn` function and returns an objec

It returns separated version of list or string `input`, where separation is done with equality `compareFn` function.

<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20compareFn%20%3D%20(x%2C%20y)%20%3D%3E%20x%20%3D%3D%3D%20y%0Aconst%20list%20%3D%20%5B1%2C%202%2C%202%2C%201%2C%201%2C%202%5D%0A%0Aconst%20result%20%3D%20R.groupWith(isConsecutive%2C%20list)%0A%2F%2F%20%3D%3E%20%5B%5B1%5D%2C%20%5B2%2C2%5D%2C%20%5B1%2C1%5D%2C%20%5B2%5D%5D">Try this <strong>R.groupWith</strong> example in Rambda REPL</a>
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20isConsecutive%20%3D%20(x%2C%20y)%20%3D%3E%20x%20%3D%3D%3D%20y%0Aconst%20list%20%3D%20%5B1%2C%202%2C%202%2C%201%2C%201%2C%202%5D%0A%0Aconst%20result%20%3D%20R.groupWith(isConsecutive%2C%20list)%0A%2F%2F%20%3D%3E%20%5B%5B1%5D%2C%20%5B2%2C2%5D%2C%20%5B1%2C1%5D%2C%20%5B2%5D%5D">Try this <strong>R.groupWith</strong> example in Rambda REPL</a>

[![---------------](https://raw.githubusercontent.com/selfrefactor/rambda/master/files/separator.png)](#groupWith)

Expand Down Expand Up @@ -6075,10 +6084,9 @@ function ifElseFn(
condition, onTrue, onFalse
){
return (...input) => {
const conditionResult =
const conditionResult =
typeof condition === 'boolean' ? condition : condition(...input)

if (conditionResult === true){
if (Boolean(conditionResult) ){
return onTrue(...input)
}

Expand All @@ -6101,6 +6109,7 @@ import { has } from './has.js'
import { identity } from './identity.js'
import { ifElse } from './ifElse.js'
import { prop } from './prop.js'
import * as R from 'ramda'

const condition = has('foo')
const v = function (a){
Expand Down Expand Up @@ -6188,6 +6197,17 @@ test('simple arity of 2', () => {
)(1, 10)
expect(result).toBe(12)
})

test('bug 750', () => {
const value = 34;

let result = ifElse(
R.identity,
R.always('true'),
R.always('false')
)(value)
expect(result).toBe('true')
})
```

</details>
Expand Down Expand Up @@ -7603,7 +7623,7 @@ It returns the result of looping through `iterable` with `fn`.

It works with both array and object.

<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20fn%20%3D%20x%20%3D%3E%20x%20*%202%0Aconst%20fnWhenObject%20%3D%20(val%2C%20prop)%3D%3E%7B%0A%20%20return%20%60%24%7Bprop%7D-%24%7Bval%7D%60%0A%7D%0A%0Aconst%20iterable%20%3D%20%5B1%2C%202%5D%0Aconst%20obj%20%3D%20%7Ba%3A%201%2C%20b%3A%202%7D%0A%0Aconst%20result%20%3D%20%5B%20%0A%20%20R.map(fn%2C%20list)%2C%0A%20%20R.map(fnWhenObject%2C%20Record%3Cstring%2C%20unknown%3E)%0A%5D%0A%2F%2F%20%3D%3E%20%5B%20%5B1%2C%204%5D%2C%20%7Ba%3A%20'a-1'%2C%20b%3A%20'b-2'%7D%5D">Try this <strong>R.map</strong> example in Rambda REPL</a>
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20fn%20%3D%20x%20%3D%3E%20x%20*%202%0Aconst%20fnWhenObject%20%3D%20(val%2C%20prop)%3D%3E%7B%0A%20%20return%20%60%24%7Bprop%7D-%24%7Bval%7D%60%0A%7D%0A%0Aconst%20iterable%20%3D%20%5B1%2C%202%5D%0Aconst%20obj%20%3D%20%7Ba%3A%201%2C%20b%3A%202%7D%0A%0Aconst%20result%20%3D%20%5B%20%0A%20%20R.map(fn%2C%20iterable)%2C%0A%20%20R.map(fnWhenObject%2C%20obj)%0A%5D%0A%2F%2F%20%3D%3E%20%5B%20%5B2%2C%204%5D%2C%20%7Ba%3A%20'a-1'%2C%20b%3A%20'b-2'%7D%5D">Try this <strong>R.map</strong> example in Rambda REPL</a>

<details>

Expand Down Expand Up @@ -7845,7 +7865,7 @@ mapObjIndexed<T>(fn: ObjectIterator<T, T>, iterable: Dictionary<T>): Dictionary<

It works the same way as `R.map` does for objects. It is added as Ramda also has this method.

<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20fn%20%3D%20(val%2C%20prop)%20%3D%3E%20%7B%0A%20%20return%20%60%24%7Bprop%7D-%24%7Bval%7D%60%0A%7D%0A%0Aconst%20obj%20%3D%20%7Ba%3A%201%2C%20b%3A%202%7D%0A%0Aconst%20result%20%3D%20R.map(mapObjIndexed%2C%20Record%3Cstring%2C%20unknown%3E)%0A%2F%2F%20%3D%3E%20%7Ba%3A%20'a-1'%2C%20b%3A%20'b-2'%7D">Try this <strong>R.mapObjIndexed</strong> example in Rambda REPL</a>
<a title="redirect to Rambda Repl site" href="https://rambda.now.sh?const%20fn%20%3D%20(val%2C%20prop)%20%3D%3E%20%7B%0A%20%20return%20%60%24%7Bprop%7D-%24%7Bval%7D%60%0A%7D%0A%0Aconst%20obj%20%3D%20%7Ba%3A%201%2C%20b%3A%202%7D%0A%0Aconst%20result%20%3D%20R.mapObjIndexed(fn%2C%20obj)%0A%2F%2F%20%3D%3E%20%7Ba%3A%20'a-1'%2C%20b%3A%20'b-2'%7D">Try this <strong>R.mapObjIndexed</strong> example in Rambda REPL</a>

<details>

Expand Down Expand Up @@ -17264,6 +17284,14 @@ describe('R.zipWith', () => {

## ❯ CHANGELOG

9.4.0

- Fix `deno` release

- Fix too strict `true` condition in `R.ifElse` - [Issue #750](https://github.com/selfrefactor/rambda/issues/750)

- Change `R.groupBy` typings to match `@types/ramda` typings

9.3.0

- Breaking change in relation to TS typings of `R.assoc`, `R.dissoc` and `R.modify` - https://github.com/ramda/types/pull/37
Expand Down Expand Up @@ -17739,4 +17767,4 @@ Fix wrong versions in changelog

## Stargazers over time

[![Stargazers over time](https://starchart.cc/selfrefactor/rambda.svg)](https://starchart.cc/selfrefactor/rambda)
[![Stargazers over time](https://starchart.cc/selfrefactor/rambda.svg)](https://starchart.cc/selfrefactor/rambda)
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
</script>
<!-- Docsify v4 -->
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
<script src="//cdn.jsdelivr.net/npm/docsify/lib/plugins/search.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify/lib/plugins/search.min.js"></script>
</body>
</html>
1 change: 0 additions & 1 deletion files/NEXT_VERSION_CHECKLIST.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Change `R.groupBy` typings to match `@types/ramda` typings

---
ABOVE IS DONE
Expand Down
5 changes: 2 additions & 3 deletions src/ifElse.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ function ifElseFn(
condition, onTrue, onFalse
){
return (...input) => {
const conditionResult =
const conditionResult =
typeof condition === 'boolean' ? condition : condition(...input)

if (conditionResult === true){
if (Boolean(conditionResult) ){
return onTrue(...input)
}

Expand Down

0 comments on commit faddaea

Please sign in to comment.