/** * 获取指定长度字符串,不足时前补零,超出时从右侧截取 * @public * @since @ray-js/panel-sdk 1.0.0 * @param str - 需要填充的字符串或数字 * @param count - 返回字符串的固定长度 * @returns 填充或截取后的定长字符串 * @remarks 如果原始字符串长度大于 count,会从右侧截取最后 count 位。与 toFilled 不同,该函数始终返回固定长度的字符串。 * @example 基础用法 * ```ts * import { utils } from '@ray-js/panel-sdk'; * * const { toFixed } = utils; * * toFixed('111', 5); // '00111' * toFixed('3456111', 5); // '56111' * toFixed(42, 4); // '0042' * ``` */ export declare const toFixed: (str: string | number, count: number) => string; /** * 将字符串用前导零填充到指定最小长度 * @public * @since @ray-js/panel-sdk 1.0.0 * @param str - 需要填充的字符串 * @param count - 返回字符串的最小长度 * @returns 填充后的字符串;若原始长度已 >= count,则原样返回 * @remarks 与 toFixed 不同,当原始字符串长度已经大于等于 count 时,不会截断。 * @example 基础用法 * ```ts * import { utils } from '@ray-js/panel-sdk'; * * const { toFilled } = utils; * * toFilled('111', 5); // '00111' * toFilled('3456111', 5); // '3456111' * ``` */ export declare const toFilled: (str: string, count: number) => string; /** * 将字符串按指定长度分割为子字符串数组 * @public * @since @ray-js/panel-sdk 1.0.0 * @param str - 需要分割的原始字符串 * @param chunk - 每个子字符串的长度 * @returns 分割后的字符串数组,最后一个元素长度可能小于 chunk * @example 基础用法 * ```ts * import { utils } from '@ray-js/panel-sdk'; * * const { partition } = utils; * * partition('1234567', 3); // ['123', '456', '7'] * partition('AABB', 2); // ['AA', 'BB'] * ``` */ export declare const partition: (str: string, chunk: number) => string[]; /** * 判断给定值是否为对象类型 * @since @ray-js/panel-sdk 1.0.0 * @param obj - 待检测的值 * @returns 如果是对象类型返回 true,否则返回 false * @example 基础用法 * ```ts * import { utils } from '@ray-js/panel-sdk'; * * const { isObject } = utils; * * isObject({}); // true * isObject([1, 2]); // true * isObject('string'); // false * isObject(null); // false * ``` */ export declare const isObject: (obj: any) => boolean; /** * 判断给定值是否为数组类型 * @since @ray-js/panel-sdk 1.0.0 * @param obj - 待检测的值 * @returns 如果是数组类型返回 true,否则返回 false * @example 基础用法 * ```ts * import { utils } from '@ray-js/panel-sdk'; * * const { isArray } = utils; * * isArray([1, 2, 3]); // true * isArray('string'); // false * ``` */ export declare const isArray: (obj: any) => boolean; /** * 判断给定值是否为 Date 日期类型 * @since @ray-js/panel-sdk 1.0.0 * @param obj - 待检测的值 * @returns 如果是 Date 类型返回 true,否则返回 false * @example 基础用法 * ```ts * import { utils } from '@ray-js/panel-sdk'; * * const { isDate } = utils; * * isDate(new Date()); // true * isDate('2024-01-01'); // false * ``` */ export declare const isDate: (obj: any) => boolean; /** * 判断给定值是否为正则表达式类型 * @since @ray-js/panel-sdk 1.0.0 * @param obj - 待检测的值 * @returns 如果是 RegExp 类型返回 true,否则返回 false * @example 基础用法 * ```ts * import { utils } from '@ray-js/panel-sdk'; * * const { isRegExp } = utils; * * isRegExp(/test/); // true * isRegExp(new RegExp('test')); // true * isRegExp('test'); // false * ``` */ export declare const isRegExp: (obj: any) => boolean; /** * 判断给定值是否为布尔类型 * @since @ray-js/panel-sdk 1.0.0 * @param obj - 待检测的值 * @returns 如果是 Boolean 类型返回 true,否则返回 false * @example 基础用法 * ```ts * import { utils } from '@ray-js/panel-sdk'; * * const { isBoolean } = utils; * * isBoolean(true); // true * isBoolean(new Boolean(false)); // true * isBoolean(0); // false * ``` */ export declare const isBoolean: (obj: any) => boolean; /** * 判断给定值是否为数字类型 * @since @ray-js/panel-sdk 1.0.0 * @param obj - 待检测的值 * @returns 如果是 Number 类型返回 true,否则返回 false * @remarks 包括 NaN 和 Infinity 等特殊数字值也会返回 true。 * @example 基础用法 * ```ts * import { utils } from '@ray-js/panel-sdk'; * * const { isNumerical } = utils; * * isNumerical(123); // true * isNumerical(NaN); // true * isNumerical('123'); // false * ``` */ export declare const isNumerical: (obj: any) => boolean; /** * 判断给定值是否为 undefined * @since @ray-js/panel-sdk 1.0.0 * @param obj - 待检测的值 * @returns 如果是 undefined 返回 true,否则返回 false * @example 基础用法 * ```ts * import { utils } from '@ray-js/panel-sdk'; * * const { isUndefined } = utils; * * isUndefined(undefined); // true * isUndefined(null); // false * isUndefined(0); // false * ``` */ export declare const isUndefined: (obj: any) => boolean; /** * 判断给定值是否为 null 或 undefined * @since @ray-js/panel-sdk 1.0.0 * @param obj - 待检测的值 * @returns 如果是 null 或 undefined 返回 true,否则返回 false * @example 基础用法 * ```ts * import { utils } from '@ray-js/panel-sdk'; * * const { isNil } = utils; * * isNil(null); // true * isNil(undefined); // true * isNil(0); // false * isNil(''); // false * ``` */ export declare const isNil: (obj: any) => boolean; /** * 根据路径字符串安全地获取嵌套对象的属性值(lodash.get 的轻量替代) * @public * @since @ray-js/panel-sdk 1.0.0 * @param object - 要查询的源对象 * @param pathString - 属性路径,使用点号分隔,如 'a.b.c' * @param defaultValue - 当路径解析结果为 undefined 时返回的默认值 * @returns 路径对应的属性值,若未找到则返回 defaultValue * @example 基础用法 * ```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 * ``` */ export declare const get: (object: Record, pathString: string, defaultValue?: string | number | boolean | Record) => string | number | boolean | Record | undefined; /** * 从对象中选取指定键的属性,返回新对象(lodash.pick 的轻量替代) * @public * @since @ray-js/panel-sdk 1.0.0 * @param object - 源对象 * @param keys - 需要选取的属性键名数组 * @returns 仅包含指定键的新对象 * @example 基础用法 * ```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']); // {} * ``` */ export declare const pick: (object: Record, keys: string[]) => Record; /** * 从对象中排除指定键的属性,返回新对象(lodash.omit 的轻量替代) * @public * @since @ray-js/panel-sdk 1.0.0 * @param object - 源对象 * @param keys - 需要排除的属性键名数组 * @returns 排除指定键后的新对象(浅拷贝) * @typeOverride returns Record * @example 基础用法 * ```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 } * ``` */ export declare const omit: (object: Record, keys: string[]) => { [x: string]: unknown; }; /** * 将数组按指定大小分割为多个子数组(lodash.chunk 的轻量替代) * @public * @since @ray-js/panel-sdk 1.0.0 * @param arr - 需要分割的原始数组 * @param chunkSize - 每个子数组的大小,默认为 1 * @param cache - 内部递归用缓存数组,通常无需传入 * @returns 分割后的二维数组 * @typeOverride chunkSize number * @example 基础用法 * ```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']] * ``` */ export declare const chunk: (arr: any[], chunkSize?: number, cache?: any[]) => any[]; /** * 比较两个语义化版本号字符串的大小 * @public * @since @ray-js/panel-sdk 1.0.0 * @param v1 - 第一个版本号字符串,如 '1.2.3' * @param v2 - 第二个版本号字符串,如 '1.2.4' * @returns 1 表示 v1 大于 v2,-1 表示 v1 小于 v2,0 表示相等,false 表示参数无效 * @example 基础用法 * ```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 * ``` */ export declare const compareVersion: (v1: string, v2: string) => false | 0 | 1 | -1; /** * 获取当前面板的设备 ID 或群组 ID * @since @ray-js/panel-sdk 1.0.0 * @param option - 可选参数对象,可手动指定 deviceId 或 groupId * @param option.deviceId - 手动指定的设备 ID * @param option.groupId - 手动指定的群组 ID * @returns 包含 deviceId 和 groupId 的对象 * @remarks 优先使用传入的参数,若未传入则依次从 App 实例和启动参数中获取。 * @example 基础用法 * ```ts * import { utils } from '@ray-js/panel-sdk'; * * const { getDeviceIdOrGroupId } = utils; * * // 自动从启动参数中获取 * const { deviceId, groupId } = await getDeviceIdOrGroupId(); * * // 手动指定设备 ID * const result = await getDeviceIdOrGroupId({ deviceId: 'abc123' }); * ``` */ export declare function getDeviceIdOrGroupId(option?: { deviceId?: string; groupId?: string; }): Promise<{ groupId: string | undefined; deviceId: string | undefined; }>;