Skip to content

select

过滤和映射数组

146 bytes
since v12.1.0

使用方法

同时应用过滤和映射操作,一次完成。 如果省略过滤器,返回所有非空值的映射值。

import * as _ from "radashi";
const fish = [
{
name: "Marlin",
weight: 105,
source: "ocean",
},
{
name: "Bass",
weight: 8,
source: "lake",
},
{
name: "Trout",
weight: 13,
source: "lake",
},
];
_.select(
fish,
(f) => f.weight,
(f) => f.source === "lake"
); // => [8, 13]