Ramda.when always return true using fs

I am trying to use Ramda.when to execute only if a condition is true but it’s always returning true: const bla2 = path => () => R.when(fs.existsSync(path()), console.log(path())) Is there anyway to use Ramda.when with fs.existsSync? edit: Even set false this is not working: const bla3 => () => R.when(false, console.log(‘bla’)) This is the real… Read More Ramda.when always return true using fs

How to rewrite this ramda.js code in vanilla JS

I am removing ramda from some code I’ve inherited as part of an effort to reduce the JavaScript size. But I’m stuck with the below because this line really baffles me as it apparently doesn’t operate on any object. var iterate = R.addIndex(R.forEach); The relevant code looks like this: var lis = $(el).find("ul.navbar-nav:not(.navbar-right) > li:not(.nav-more)");… Read More How to rewrite this ramda.js code in vanilla JS

Ramda – How to filter array with other array and multiple properties

I am trying to filter one array with another array using Ramda. This is an array of edges for ELK algorithm. sources and targets are arrays but in this case, those arrays have always single value. const edges = [ { "id": "47c0ffd2-6a2c-4e7f-9fd9-0e1207225ada#2789a940-15d1-4ff0-b2ef-9f6cde676c18", "sources": [ "47c0ffd2-6a2c-4e7f-9fd9-0e1207225ada" ], "targets": [ "2789a940-15d1-4ff0-b2ef-9f6cde676c18" ] }, { "id": "47c0ffd2-6a2c-4e7f-9fd9-0e1207225ada#7cf88eab-5da4-492b-839c-30916fa98fb9",… Read More Ramda – How to filter array with other array and multiple properties

Sort array from object based on a property and return the sorted initial object

I have the following object { "object": "list", "url": "/v1/prices", "has_more": false, "data": [ { "id": "price_1KHlU72eZvKYlo2CblI51Z8e", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1642150211, "currency": "usd", "livemode": false, "lookup_key": null, "metadata": {}, "nickname": null, "product": "prod_Kxgr3hZDfHnqu1", "recurring": { "aggregate_usage": null, "interval": "month", "interval_count": 1, "usage_type": "licensed" }, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type":… Read More Sort array from object based on a property and return the sorted initial object