如何使用Ramda remove从对象Array中删除空对象?

时间:2017-02-08 19:39:27

标签: javascript arrays functional-programming ramda.js

Ramda remove Ramda Repl link

以下是给定的示例,它从数组中删除特定数字:

SELECT getdate() AS DateRun, member_no member_surname, scheme, investment_code, investment_percentage, percentage_rank FROM ( SELECT b.membno AS member_no, b.surnam AS member_surname, b.scheme AS scheme, i.invcde AS Investment_Code, i.instamt AS Investment_Percentage, RANK() OVER (PARTITION BY b.membno ORDER BY i.instamt) AS percentage_rank FROM basic AS b LEFT JOIN invinst AS i ON b.membno = i.membno LEFT JOIN invcde_list AS il ON i.invcde = il.invcde WHERE b.membno >= 15000 AND b.scheme = 'ABCD' AND i.contsrc = 'EE' AND i1.enddte IS NULL ) as FinallyJoined WHERE percentage_rank < 4;

现在我创建了一个对象数组,其中一个是空的:

R.remove(2, 3, [1,2,3,4,5,6,7,8]); //=> [1,2,6,7,8]

当我尝试:

var objArray = [{id: 1, name: 'Leon'},{id: 2, name: 'Paulo'},{}];

R.remove({}, objArray);

它返回一个函数:

enter image description here

为什么会这样?

1 个答案:

答案 0 :(得分:7)

想出来:

const filteredAlerts = R.filter(Util.notEmpty, res.alerts);

我需要按非空的对象进行过滤。

这是我的Util.notEmpty功能:

const notEmpty = R.compose(R.not, R.isEmpty);