跳至主要内容

重新映射键

返回一个对象,该对象是通过从输入中提取给定的 actualKey 并将其存储为输出中的 desiredKey 而得到的。

用法

const $mapped = remapKeys(
$original,

// Take the `first_name` and `id` properties of the original object, and
// return a new object where these are stored into the `name` and `row_id`
// properties respectively.
{
name: "first_name",
row_id: "id",
},
);
提示

此步骤在优化阶段特别有用,如果您的步骤成功地内联到祖先中,那么它可能需要转换祖先才能返回与没有此优化时等效的结果。

待办事项:此提示措辞不当。