---
name: "toFixed"
mode: "api"
versionRequirements:
  - { name: "@ray-js/panel-sdk", version: "1.0.0" }
title: "core"
---

## toFixed

> [VERSION] @ray-js/panel-sdk >= 1.0.0

> 💡 If the original string length is greater than count, take the last count characters from the right. Unlike toFilled, this function always returns a fixed-length string.

### Description

Get a string of the specified length; pad with leading zeros if shorter, or truncate from the right if longer.

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `str` | `string \| number` | Yes | The string or number to pad |
| `count` | `number` | Yes | The fixed length of the returned string |

### Return Value

None


### Examples

#### Basic usage

```ts
import { utils } from '@ray-js/panel-sdk';

const { toFixed } = utils;

toFixed('111', 5);    // '00111'
toFixed('3456111', 5); // '56111'
toFixed(42, 4);        // '0042'
```

---
name: "toFilled"
mode: "api"
versionRequirements:
  - { name: "@ray-js/panel-sdk", version: "1.0.0" }
title: "core"
---
## toFilled

> [VERSION] @ray-js/panel-sdk >= 1.0.0

> 💡 Unlike toFixed, when the original string length is already greater than or equal to count, it will not truncate.

### Description

Pad a string with leading zeros to the specified minimum length

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `str` | `string` | Yes | The string to pad |
| `count` | `number` | Yes | The minimum length of the returned string |

### Return Value

None


### Examples

#### Basic usage

```ts
import { utils } from '@ray-js/panel-sdk';

const { toFilled } = utils;

toFilled('111', 5);     // '00111'
toFilled('3456111', 5); // '3456111'
```

---
name: "partition"
mode: "api"
versionRequirements:
  - { name: "@ray-js/panel-sdk", version: "1.0.0" }
title: "core"
---
## partition

> [VERSION] @ray-js/panel-sdk >= 1.0.0

### Description

Split a string into an array of substrings of the specified length

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `str` | `string` | Yes | The original string to split |
| `chunk` | `number` | Yes | The length of each substring |

### Return Value

Type: `string[]`

The resulting array of substrings; the last element may be shorter than chunk

### Examples

#### Basic usage

```ts
import { utils } from '@ray-js/panel-sdk';

const { partition } = utils;

partition('1234567', 3); // ['123', '456', '7']
partition('AABB', 2);    // ['AA', 'BB']
```

---
name: "get"
mode: "api"
versionRequirements:
  - { name: "@ray-js/panel-sdk", version: "1.0.0" }
title: "core"
---
## get

> [VERSION] @ray-js/panel-sdk >= 1.0.0

### Description

Safely get a nested property value by a path string (a lightweight alternative to lodash.get)

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `object` | `Record<string, any>` | Yes | The source object to query |
| `pathString` | `string` | Yes | Property path, dot-separated, e.g., 'a.b.c' |
| `defaultValue` | `string \| number \| false \| true \| Record<string, any>` | No | The default value to return when the resolved path is undefined |

### Return Value

Type: `string \| number \| false \| true \| Record<string, any>`

The value at the given path, or defaultValue if not found

### Examples

#### Basic usage

```ts
import { utils } from '@ray-js/panel-sdk';

const { get } = utils;

const obj = { a: { b: { c: 42 } } };
get(obj, 'a.b.c');          // 42
get(obj, 'a.b.x', 'N/A');  // 'N/A'
get(obj, 'a.b.c.d');       // undefined
```

---
name: "pick"
mode: "api"
versionRequirements:
  - { name: "@ray-js/panel-sdk", version: "1.0.0" }
title: "core"
---
## pick

> [VERSION] @ray-js/panel-sdk >= 1.0.0

### Description

Pick specified keys from an object and return a new object (a lightweight alternative to lodash.pick)

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `object` | `Record<string, unknown>` | Yes | Source object |
| `keys` | `string[]` | Yes | An array of property keys to pick |

### Return Value

Type: `Record<string, unknown>`

A new object containing only the specified keys

### Examples

#### Basic usage

```ts
import { utils } from '@ray-js/panel-sdk';

const { pick } = utils;

const obj = { a: 1, b: 2, c: 3 };
pick(obj, ['a', 'c']); // { a: 1, c: 3 }
pick(obj, ['d']);       // {}
```

---
name: "omit"
mode: "api"
versionRequirements:
  - { name: "@ray-js/panel-sdk", version: "1.0.0" }
title: "core"
---
## omit

> [VERSION] @ray-js/panel-sdk >= 1.0.0

### Description

Omit specified keys from an object and return a new object (a lightweight alternative to lodash.omit)

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `object` | `Record<string, unknown>` | Yes | Source object |
| `keys` | `string[]` | Yes | An array of property keys to omit |

### Return Value

Type: `Record<string, unknown>`

A new object with the specified keys omitted (shallow copy)

### Examples

#### Basic usage

```ts
import { utils } from '@ray-js/panel-sdk';

const { omit } = utils;

const obj = { a: 1, b: 2, c: 3 };
omit(obj, ['b']);      // { a: 1, c: 3 }
omit(obj, ['a', 'c']); // { b: 2 }
```

---
name: "chunk"
mode: "api"
versionRequirements:
  - { name: "@ray-js/panel-sdk", version: "1.0.0" }
title: "core"
---
## chunk

> [VERSION] @ray-js/panel-sdk >= 1.0.0

### Description

Split an array into multiple subarrays of the specified size (a lightweight alternative to lodash.chunk)

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `arr` | `any[]` | Yes | The original array to split |
| `chunkSize` | `number` | No | The size of each subarray, default is 1 |
| `cache` | `any[]` | No | Cache array for internal recursion; typically not needed to pass |

### Return Value

Type: `any[]`

The resulting two-dimensional array

### Examples

#### Basic usage

```ts
import { utils } from '@ray-js/panel-sdk';

const { chunk } = utils;

chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]
chunk(['a', 'b', 'c'], 1); // [['a'], ['b'], ['c']]
```

---
name: "compareVersion"
mode: "api"
versionRequirements:
  - { name: "@ray-js/panel-sdk", version: "1.0.0" }
title: "core"
---
## compareVersion

> [VERSION] @ray-js/panel-sdk >= 1.0.0

### Description

Compare the order of two semantic version strings

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `v1` | `string` | Yes | The first version string, e.g., '1.2.3' |
| `v2` | `string` | Yes | The second version string, e.g., '1.2.4' |

### Return Value

Type: `false \| 0 \| 1 \| -1`

1 means v1 is greater than v2, -1 means v1 is less than v2, 0 means equal, false means invalid arguments

### Examples

#### Basic usage

```ts
import { utils } from '@ray-js/panel-sdk';

const { compareVersion } = utils;

compareVersion('1.2.3', '1.2.4'); // -1
compareVersion('2.0.0', '1.9.9'); // 1
compareVersion('1.0.0', '1.0.0'); // 0
compareVersion(null, '1.0.0');    // false
```
