|
1 |
| -If you open a PR that introduces a new function, add it to the "New Functions" section. If you're extending an existing function, add it to the "New Features" section. |
| 1 | +## New Functions |
2 | 2 |
|
3 |
| -The `####` headline should be short and descriptive of the new functionality. In the body of the section, include a link to the PR. You don't need to include a description of the change itself, as we will extract that from the documentation. |
| 3 | +#### Add `concat` function [#388](https://github.com/radashi-org/radashi/pull/388) |
4 | 4 |
|
5 |
| -## New Functions |
| 5 | +Flattens and filters nullish values from arguments. |
| 6 | + |
| 7 | +```ts |
| 8 | +import { concat } from 'radashi' |
| 9 | + |
| 10 | +const result = concat('a', null, ['b', undefined], 'c') |
| 11 | +// => ['a', 'b', 'c'] |
| 12 | +``` |
| 13 | + |
| 14 | +🔗 [Docs](https://radashi.js.org/reference/array/concat) / [Source](https://github.com/radashi-org/radashi/blob/main/src/array/concat.ts) / [Tests](https://github.com/radashi-org/radashi/blob/main/tests/array/concat.test.ts) |
| 15 | + |
| 16 | +#### Add `pluck` function [#376](https://github.com/radashi-org/radashi/pull/376) |
| 17 | + |
| 18 | +Map an array of objects to an array of arrays. |
| 19 | + |
| 20 | +```ts |
| 21 | +import { pluck } from 'radashi' |
| 22 | + |
| 23 | +const gods = [ |
| 24 | + { name: 'Ra', power: 100 }, |
| 25 | + { name: 'Zeus', power: 98 }, |
| 26 | +] |
| 27 | + |
| 28 | +const names = pluck(gods, ['name']) |
| 29 | +// => [['Ra'], ['Zeus']] |
| 30 | +``` |
| 31 | + |
| 32 | +Thanks to [@nusohiro](https://github.com/nusohiro) for the contribution! |
| 33 | + |
| 34 | +🔗 [Docs](https://radashi.js.org/reference/array/pluck) / [Source](https://github.com/radashi-org/radashi/blob/main/src/array/pluck.ts) / [Tests](https://github.com/radashi-org/radashi/blob/main/tests/array/pluck.test.ts) |
| 35 | + |
| 36 | +## <!-- 06 -->Fixed |
| 37 | + |
| 38 | +#### Fix `mapify` index argument [#384](https://github.com/radashi-org/radashi/pull/384) |
| 39 | + |
| 40 | +Ensure the index argument passed to `mapify`'s 2nd callback is the actual array index. |
| 41 | + |
| 42 | +```ts |
| 43 | +import { mapify } from 'radashi' |
| 44 | + |
| 45 | +const list = [ |
| 46 | + { id: 'a', word: 'hello' }, |
| 47 | + { id: 'a', word: 'bye' }, |
| 48 | + { id: 'a', word: 'oh' }, |
| 49 | +] |
| 50 | + |
| 51 | +const result = mapify( |
| 52 | + list, |
| 53 | + x => x.id, |
| 54 | + (x, i) => x.word + i, |
| 55 | +) |
| 56 | +// => Map { 'a' => 'oh2' } |
| 57 | +``` |
| 58 | + |
| 59 | +Thanks to [@Yukiniro](https://github.com/Yukiniro) for the contribution! |
| 60 | + |
| 61 | +#### Avoid infinite loop in `cluster` when size is `0` [#397](https://github.com/radashi-org/radashi/pull/397) |
| 62 | + |
| 63 | +The `cluster` function now correctly handles the case where the size is `0` or less by returning an empty array. |
| 64 | + |
| 65 | +```ts |
| 66 | +import { cluster } from 'radashi' |
| 67 | + |
| 68 | +const result = cluster([1, 2, 3], 0) |
| 69 | +// => [] |
| 70 | +``` |
| 71 | + |
| 72 | +Thanks to [@fResult](https://github.com/fResult) for the contribution! |
| 73 | + |
| 74 | +## <!-- 08 -->Types |
6 | 75 |
|
7 |
| -#### Add `concat` function |
| 76 | +#### Improve `cluster` type inference [#389](https://github.com/radashi-org/radashi/pull/389) |
8 | 77 |
|
9 |
| -https://github.com/radashi-org/radashi/pull/388 |
| 78 | +The `cluster` function now provides precise type inference for common cluster sizes (1-8) using tuple types. |
10 | 79 |
|
11 |
| -## New Features |
| 80 | +```ts |
| 81 | +import { cluster } from 'radashi' |
12 | 82 |
|
13 |
| -#### Improve `cluster` type inference |
| 83 | +const result = cluster(['a', 'b', 'c', 'd'], 2) |
| 84 | +// ^? [string, string][] |
| 85 | +``` |
14 | 86 |
|
15 |
| -https://github.com/radashi-org/radashi/pull/389 |
| 87 | +Thanks to [@fResult](https://github.com/fResult) for the contribution! |
0 commit comments