remove
通过移除满足谓词函数的元素来过滤数组
63 bytes
currently in beta
使用方法
传入一个数组和一个谓词函数。该函数返回一个新数组,不包含满足谓词条件的元素,而不会改变原始数组。
import * as _ from "radashi";
const numbers = [1, 2, 3, 4, 5];const result = _.remove(numbers, (value) => value % 2 === 0);console.log(result); // => [1, 3, 5]
const objects = [ { id: 1, active: true }, { id: 2, active: false }, { id: 3, active: true },];const result = _.remove(objects, (obj) => obj.active);console.log(result); // => [{ id: 2, active: false }]