selfrefactor / rambdax

Extended version of Rambda
https://selfrefactor.github.io/rambdax
MIT License
221 stars 26 forks source link

mapArray filterArray curried error #74

Closed moczix closed 2 years ago

moczix commented 3 years ago

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch rambdax@7.4.0 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/rambdax/dist/rambdax.esm.js b/node_modules/rambdax/dist/rambdax.esm.js
index 40b97d1..d2828f9 100644
--- a/node_modules/rambdax/dist/rambdax.esm.js
+++ b/node_modules/rambdax/dist/rambdax.esm.js
@@ -554,6 +554,7 @@ function filterObject(predicate, obj) {
   return willReturn;
 }
 function filterArray(predicate, list, indexed = false) {
+  if (arguments.length === 1) return _list => filterArray(predicate, _list);
   let index = 0;
   const len = list.length;
   const willReturn = [];
@@ -644,6 +645,7 @@ function filterIndexed(predicate, iterable) {
 const _keys = Object.keys;

 function mapArray(fn, list, isIndexed = false) {
+  if (arguments.length === 1) return _list => map(fn, _list);
   let index = 0;
   const willReturn = Array(list.length);

@@ -655,6 +657,7 @@ function mapArray(fn, list, isIndexed = false) {
   return willReturn;
 }
 function mapObject(fn, obj) {
+  if (arguments.length === 1) return _obj => mapObject(fn, _obj);
   let index = 0;

   const keys = _keys(obj);
diff --git a/node_modules/rambdax/dist/rambdax.js b/node_modules/rambdax/dist/rambdax.js
index 4fba505..3715a8c 100644
--- a/node_modules/rambdax/dist/rambdax.js
+++ b/node_modules/rambdax/dist/rambdax.js
@@ -558,6 +558,7 @@ function filterObject(predicate, obj) {
   return willReturn;
 }
 function filterArray(predicate, list, indexed = false) {
+  if (arguments.length === 1) return _list => filterArray(predicate, _list);
   let index = 0;
   const len = list.length;
   const willReturn = [];

This issue body was partially generated by patch-package.

selfrefactor commented 3 years ago

Thanks for the report. When I added these methods, I omitted currying in TS definitions on purpose. Will look into the issue and will report back.

selfrefactor commented 3 years ago

I am currently in a sick leave, but afterwards I will look into the issue.

selfrefactor commented 2 years ago

I will need more info on that one as currently npx patch-package rambdax doesn't return an error, i.e. there is no error in Rambdax version 7.4.1.

I will close the issue as I cannot reproduce it, but feel free to comment further.