UNPKG

ut2

Version:

一个现代 JavaScript 实用工具库。[点击查看在线文档]。

31 lines (30 loc) 899 B
import { TPath } from './internals/types'; /** * 将对象转为属性路径/值对的数组。与 [`fromPathPairs`](#.fromPathPairs) 相反。 * * @alias module:Object.pathPairs * @since 1.16.0 * @param {Object|Array} object 对象或数组。 * @returns {Array} 属性路径/值对的数组。 * @example * pathPairs({ date: { start: '2024-10-10', end: '2024-12-31' } }); * // [ * // [['date', 'start'], '2024-10-10'], * // [['date', 'end'], '2024-12-31'] * // ] * * pathPairs({ date: ['2024-10-10', '2024-12-31'] }); * // [ * // [['date', 0], '2024-10-10'], * // [['date', 1], '2024-12-31'] * // ] * * pathPairs([{ date: '2024-10-10' }, { date: '2024-12-31' }]); * // [ * // [[0, 'date'], '2024-10-10'], * // [[1, 'date'], '2024-12-31'] * // ] * */ declare function pathPairs(object: Record<string, any> | any[]): [TPath[], any][]; export default pathPairs;