toFixed(str: string | number, count: number)
Requires:
@ray-js/panel-sdk≥1.0.0
Description
Get a string of the specified length; pad with leading zeros if shorter, or truncate from the right if longer.
Parameters
| 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
Type: string
The fixed-length string after padding or truncation
Examples
Basic usage
toFilled(str: string, count: number)
Requires:
@ray-js/panel-sdk≥1.0.0
Description
Pad a string with leading zeros to the specified minimum length
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
str | string | Yes | The string to pad |
count | number | Yes | The minimum length of the returned string |
Return Value
Type: string
The padded string; if the original length is already >= count, it is returned as is
Examples
Basic usage
partition(str: string, chunk: number)
Requires:
@ray-js/panel-sdk≥1.0.0
Description
Split a string into an array of substrings of the specified length
Parameters
| 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
get(object: Record<string, any>, pathString: string, defaultValue?: string | number | false | true | Record<string, any>)
Requires:
@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
| Parameter | Type | Required | Description |
|---|---|---|---|
| Yes | The source object to query | ||
pathString | string | Yes | Property path, dot-separated, e.g., 'a.b.c' |
| 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
pick(object: Record<string, unknown>, keys: string[])
Requires:
@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
| Parameter | Type | Required | Description |
|---|---|---|---|
| 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
omit(object: Record<string, unknown>, keys: string[])
Requires:
@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
| Parameter | Type | Required | Description |
|---|---|---|---|
| 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
chunk(arr: any[], chunkSize?: number, cache?: any[])
Requires:
@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
| 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
compareVersion(v1: string, v2: string)
Requires:
@ray-js/panel-sdk≥1.0.0
Description
Compare the order of two semantic version strings
Parameters
| 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
Valid Values
return
| Value | Description | Since |
|---|---|---|
false | - | - |
0 | - | - |
1 | - | - |
-1 | - | - |