Skip to content

Commit 0b2257f

Browse files
committed
Rename some stuff
1 parent 7bb9cc6 commit 0b2257f

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Inspired by [Elixir's `cond`](https://elixir-lang.org/getting-started/case-cond-and-if.html#cond) this is a simpler alternative to [lodash's `_.cond`](https://lodash.com/docs/4.17.15#cond)
44

5-
[![codecov](https://codecov.io/gh/erikmueller/cond-flow/branch/master/graph/badge.svg)](https://codecov.io/gh/erikmueller/cond-flow)
5+
[![codecov](https://codecov.io/gh/erikmueller/cond-flow/branch/master/graph/badge.svg?token=WCNYJSZK51)](https://codecov.io/gh/erikmueller/cond-flow)
66

77
## Install
88

@@ -32,7 +32,7 @@ const value = cond([
3232
// value === 'true'
3333
```
3434

35-
Also works nicely with React components as you can have the values lazily evaluated by wrapping it in a function:
35+
Also works nicely with React components as you can have the values lazily evaluated by wrapping them in a function:
3636

3737
```jsx
3838
import cond from 'cond-flow'
@@ -48,9 +48,9 @@ const Component = ({ isDisabled, isNew, isLoading }) => (
4848
)
4949
```
5050

51-
### Fallback
51+
### Default return value
5252

53-
You can provide a fallback which will be returned if no provided conditions are met.
53+
You can provide a `default` fallback which will be returned if no provided conditions are met.
5454

5555
```js
5656
import cond from 'cond-flow'
@@ -60,7 +60,7 @@ const value = cond(
6060
[false, () => 'false'],
6161
[false, () => 'also false'],
6262
],
63-
{ fallback: () => 'fallback' },
63+
{ default: () => 'fallback' },
6464
)
6565

6666
// value === 'fallback'

src/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ it("returns undefined if no predicate evaluates to true", () => {
1919

2020
it("returns provided fallback if no predicate evaluates to true", () => {
2121
const value = cond([[false, "false"]], {
22-
fallback: () => "fallback",
22+
default: () => "fallback",
2323
});
2424

2525
expect(value).toBe("fallback");

src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ type Pairs<T> = [boolean, Value<T>][];
44

55
type Options<T> = {
66
/**
7-
* If no match is found, the fallback is returned instead.
7+
* If no match is found, the default is returned instead.
88
* @default undefined
99
*/
10-
fallback?: Value<T>;
10+
default?: Value<T>;
1111
};
1212

1313
// Ignoring rule to allow for usage of interface
@@ -16,7 +16,7 @@ interface Cond {
1616
<T, F extends undefined>(pairs: Pairs<T>, options?: F): T | undefined;
1717
<T, F extends Value<T>>(
1818
pairs: Pairs<T>,
19-
options?: { fallback: F },
19+
options?: { default: F },
2020
): F extends Value<T> ? T : T | undefined;
2121
<T>(pairs: Pairs<T>, options?: Options<T>): T | undefined;
2222
}
@@ -32,7 +32,7 @@ function processMatch<T>(match: Value<T>): T {
3232

3333
const cond: Cond = <T, F>(pairs: Pairs<T>, options?: Options<F>) => {
3434
const found = pairs.find(([predicate]) => predicate);
35-
const match = found === undefined ? options?.fallback : found[1];
35+
const match = found === undefined ? options?.default : found[1];
3636

3737
return processMatch(match);
3838
};

0 commit comments

Comments
 (0)