@dxtmisha/wiki 0.59.0 → 0.59.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Meta } from '@storybook/addon-docs/blocks'
|
|
2
|
+
|
|
3
|
+
<Meta title='@dxtmisha/en/functional-basic/Functions/getFirst - Get the first element'/>
|
|
4
|
+
|
|
5
|
+
# `getFirst`
|
|
6
|
+
|
|
7
|
+
Returns the first element of an array or object. If the value is a primitive, returns the value itself.
|
|
8
|
+
|
|
9
|
+
**Parameters:**
|
|
10
|
+
- `value: T | T[] | Record<string, T>` — input value.
|
|
11
|
+
|
|
12
|
+
**Returns:**
|
|
13
|
+
`T | undefined` — the first element of the array or object, or the value itself.
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { getFirst } from '@dxtmisha/functional-basic'
|
|
17
|
+
|
|
18
|
+
console.log(getFirst([1, 2, 3])) // 1
|
|
19
|
+
console.log(getFirst({ a: 1, b: 2 })) // 1
|
|
20
|
+
console.log(getFirst('string')) // 'string'
|
|
21
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Meta } from '@storybook/addon-docs/blocks'
|
|
2
|
+
|
|
3
|
+
<Meta title='@dxtmisha/ru/functional-basic/Functions/getFirst - Получение первого элемента'/>
|
|
4
|
+
|
|
5
|
+
# `getFirst`
|
|
6
|
+
|
|
7
|
+
Возвращает первый элемент массива или объекта. Если значение является примитивом, возвращает само значение.
|
|
8
|
+
|
|
9
|
+
**Параметры:**
|
|
10
|
+
- `value: T | T[] | Record<string, T>` — входное значение.
|
|
11
|
+
|
|
12
|
+
**Возвращает:**
|
|
13
|
+
`T | undefined` — первый элемент массива или объекта, или само значение.
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { getFirst } from '@dxtmisha/functional-basic'
|
|
17
|
+
|
|
18
|
+
console.log(getFirst([1, 2, 3])) // 1
|
|
19
|
+
console.log(getFirst({ a: 1, b: 2 })) // 1
|
|
20
|
+
console.log(getFirst('string')) // 'string'
|
|
21
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Meta } from '@storybook/addon-docs/blocks'
|
|
2
|
+
|
|
3
|
+
<Meta title='@dxtmisha/vi/functional-basic/Functions/getFirst - Lấy phần tử đầu tiên'/>
|
|
4
|
+
|
|
5
|
+
# `getFirst`
|
|
6
|
+
|
|
7
|
+
Trả về phần tử đầu tiên của một mảng hoặc một đối tượng. Nếu giá trị là kiểu nguyên thủy, trả về chính giá trị đó.
|
|
8
|
+
|
|
9
|
+
**Tham số:**
|
|
10
|
+
- `value: T | T[] | Record<string, T>` — giá trị đầu vào.
|
|
11
|
+
|
|
12
|
+
**Trả về:**
|
|
13
|
+
`T | undefined` — phần tử đầu tiên của mảng hoặc đối tượng, hoặc chính giá trị đó.
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { getFirst } from '@dxtmisha/functional-basic'
|
|
17
|
+
|
|
18
|
+
console.log(getFirst([1, 2, 3])) // 1
|
|
19
|
+
console.log(getFirst({ a: 1, b: 2 })) // 1
|
|
20
|
+
console.log(getFirst('string')) // 'string'
|
|
21
|
+
```
|