Skip to content

Commit

Permalink
chore: fix typo in example
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Jul 23, 2024
1 parent bea5648 commit ad2e620
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/array/selectFirst.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ This function is particularly useful when you need to find and transform an elem
- Returns `undefined` if no element satisfies the condition or if the array is empty/nullish

```typescript
import { selectFirst } from './selectFirst'
import * as _ from 'radashi'

// Find the first even number and double it
selectFirst(
_.selectFirst(
[1, 3, 4, 6, 8],
x => x * 2,
x => x % 2 === 0,
)
// => 8

// Find the first non-empty string and convert to uppercase
selectFirst(
_.selectFirst(
['', null, 'hello', 'world'],
s => s?.toUpperCase(),
s => s !== null && s !== '',
Expand All @@ -40,14 +40,14 @@ const users = [
{ id: 2, name: 'Bob', age: 25 },
{ id: 3, name: 'Charlie', age: 35 },
]
selectFirst(
_.selectFirst(
users,
user => user.name,
user => user.age > 30,
)
// => 'Charlie'

// Using default condition (non-nullish)
selectFirst([null, undefined, 0, '', false, 'found'], x => x)
_.selectFirst([null, undefined, 0, '', false, 'found'], x => x)
// => 0
```

0 comments on commit ad2e620

Please sign in to comment.