Skip to content

Commit

Permalink
Update docs for v10+ (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
sodiray authored Dec 31, 2022
1 parent 7c77908 commit 8949bf9
Show file tree
Hide file tree
Showing 47 changed files with 764 additions and 472 deletions.
1 change: 1 addition & 0 deletions chiller.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"light": "docs/logo-light.png",
"dark": "docs/logo-dark.png"
},
"version": "v10.x.x",
"index": "docs/getting-started",
"pages": "./docs/**/*.mdx",
"theme": "red-400",
Expand Down
34 changes: 18 additions & 16 deletions docs/array/alphabetical.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ group: 'Array'
description: Sorts an array of objects alphabetically by a property
---




## Basic usage

Given an array of objects and a callback function used to determine
Expand All @@ -16,19 +13,24 @@ sorted alphabetically.
```ts
import { alphabetical } from 'radash'

const gods = [{
name: 'Ra',
power: 100
}, {
name: 'Zeus',
power: 98
}, {
name: 'Loki',
power: 72
}, {
name: 'Vishnu',
power: 100
}]
const gods = [
{
name: 'Ra',
power: 100
},
{
name: 'Zeus',
power: 98
},
{
name: 'Loki',
power: 72
},
{
name: 'Vishnu',
power: 100
}
]

alphabetical(gods, g => g.name) // => [Loki, Ra, Vishnu, Zeus]
alphabetical(gods, g => g.name, 'desc') // => [Zeus, Vishnu, Ra, Loki]
Expand Down
34 changes: 18 additions & 16 deletions docs/array/boil.mdx
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
---
title: boil
group: 'Array'
description: "Reduce a list of items down to one item"
description: 'Reduce a list of items down to one item'
---




## Basic usage

Given an array of items return the final item that wins the comparison condition. Useful for more complicated min/max.

```ts
import { boil } from 'radash'

const gods = [{
name: 'Ra',
power: 100
}, {
name: 'Zeus',
power: 98
}, {
name: 'Loki',
power: 72
}]

const mostPowerful = boil(gods, (a, b) => a.power > b.power ? a : b) // => { name: 'Ra', power: 100 }
const gods = [
{
name: 'Ra',
power: 100
},
{
name: 'Zeus',
power: 98
},
{
name: 'Loki',
power: 72
}
]

boil(gods, (a, b) => (a.power > b.power ? a : b))
// => { name: 'Ra', power: 100 }
```
15 changes: 2 additions & 13 deletions docs/array/cluster.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,16 @@ group: 'Array'
description: Split a list into many lists of the given size
---




## Basic usage

Given an array of items and a desired cluster size (`n`), returns an array
Given an array of items and a desired cluster size (`n`), returns an array
of arrays. Each child array containing `n` (cluster size) items
split as evenly as possible.

```ts
import { cluster } from 'radash'

const gods = [
'Ra',
'Zeus',
'Loki',
'Vishnu',
'Icarus',
'Osiris',
'Thor'
]
const gods = ['Ra', 'Zeus', 'Loki', 'Vishnu', 'Icarus', 'Osiris', 'Thor']

cluster(gods, 3)
// => [
Expand Down
27 changes: 14 additions & 13 deletions docs/array/counting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ group: 'Array'
description: Creates an object with counts of occurrences of items
---




## Basic usage

Given an array of objects and an identity callback function to determine
Expand All @@ -17,16 +14,20 @@ telling how many times that id occurred.
```ts
import { counting } from 'radash'

const gods = [{
name: 'Ra',
culture: 'egypt'
}, {
name: 'Zeus',
culture: 'greek'
}, {
name: 'Loki',
culture: 'greek'
}]
const gods = [
{
name: 'Ra',
culture: 'egypt'
},
{
name: 'Zeus',
culture: 'greek'
},
{
name: 'Loki',
culture: 'greek'
}
]

counting(gods, g => g.culture) // => { egypt: 1, greek: 2 }
```
10 changes: 0 additions & 10 deletions docs/array/diff.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ group: 'Array'
description: Create an array of differences between two arrays
---




## Basic usage

Given two arrays, returns an array of all items that exist in the first array
Expand All @@ -20,10 +17,3 @@ const newWorldGods = ['vishnu', 'zeus']

diff(oldWorldGods, newWorldGods) // => ['ra']
```







12 changes: 1 addition & 11 deletions docs/array/first.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ group: 'Array'
description: Get the first item from a list
---




## Basic usage

Given an array of items return the first item or a default value if no items exists.
Expand All @@ -17,12 +14,5 @@ import { first } from 'radash'
const gods = ['ra', 'loki', 'zeus']

first(gods) // => 'ra'
first([], 'vishnu') // => 'vishnu'
first([], 'vishnu') // => 'vishnu'
```







15 changes: 1 addition & 14 deletions docs/array/flat.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,16 @@ group: 'Array'
description: Flatten an array of arrays into a single dimension
---




## Basic usage

Given an array that contains many arrays, return a new array where all items from the children are present at the top level.

```ts
import { flat } from 'radash'

const gods = [
['ra', 'loki'],
['zeus']
]
const gods = [['ra', 'loki'], ['zeus']]

flat(gods) // => [ra, loki, zeus]
```

Note, `_.flat` is not recursive and will not flatten children of children of children ... of children. It will only flatten `T[][]` an array of arrays.







41 changes: 18 additions & 23 deletions docs/array/fork.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,31 @@ group: 'Array'
description: Split an array into two arrays by a condition
---




## Basic usage

Given an array of items and a condition, returns two arrays where the first contains all items that passed the condition and the second contains all items that failed the condition.

```ts
import { fork } from 'radash'

const gods = [{
name: 'Ra',
power: 100
}, {
name: 'Zeus',
power: 98
}, {
name: 'Loki',
power: 72
}, {
name: 'Vishnu',
power: 100
}]
const gods = [
{
name: 'Ra',
power: 100
},
{
name: 'Zeus',
power: 98
},
{
name: 'Loki',
power: 72
},
{
name: 'Vishnu',
power: 100
}
]

const [finalGods, lesserGods] = fork(gods, f => f.power > 90) // [[ra, vishnu, zues], [loki]]
```







36 changes: 15 additions & 21 deletions docs/array/group.mdx
Original file line number Diff line number Diff line change
@@ -1,36 +1,30 @@
---
title: group
group: 'Array'
description: "Sort an array of items into groups"
description: 'Sort an array of items into groups'
---




## Basic usage

Given an array of items, `group` will build up an object where each key is an array of the items that belong in that group. Generally, this can be useful to categorize an array.

```ts
import { group } from 'radash'

const fish = [{
name: 'Marlin',
source: 'ocean'
}, {
name: 'Bass',
source: 'lake'
}, {
name: 'Trout',
source: 'lake'
}]
const fish = [
{
name: 'Marlin',
source: 'ocean'
},
{
name: 'Bass',
source: 'lake'
},
{
name: 'Trout',
source: 'lake'
}
]

const fishBySource = group(fish, f => f.source) // => { ocean: [marlin], lake: [bass, trout] }
```







10 changes: 0 additions & 10 deletions docs/array/intersects.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ group: 'Array'
description: Determine if two arrays have a common item
---




## Basic usage

Given two arrays of items, returns true if any item exists in both arrays.
Expand All @@ -23,10 +20,3 @@ const brackishFish = ['tarpon', 'snook']

intersects(oceanFish, brackishFish) // => true
```







Loading

1 comment on commit 8949bf9

@vercel
Copy link

@vercel vercel bot commented on 8949bf9 Dec 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.