ut2
Version:
一个现代 JavaScript 实用工具库。[点击查看在线文档]。
23 lines (22 loc) • 727 B
TypeScript
interface FromPairs {
<P extends string | number | symbol, V = any>(array: [P, V][]): Record<P, V>;
<P extends string | number | symbol>(array: any[][]): Record<P, any>;
}
/**
* 将键值对数组转为对象。
*
* 与 [Object.entries](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object/entries) 正好相反。
*
* @deprecated 即将废弃,请使用 `Object.fromEntries` 替代。
* @private
* @alias module:Array.fromPairs
* @since 1.0.0
* @param {Array} array 键值对数组。
* @returns {Object} 新对象。
* @example
*
* fromPairs([['foo', 'bar'], ['baz', 42]]); // {foo: 'bar', baz: 42}
*
*/
declare const fromPairs: FromPairs;
export default fromPairs;