Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(map,filter): additional arguments #326

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

tpluscode
Copy link
Contributor

I extended the map and filter steps with the option to pass any number of additional parameters for the callbacks.

Until now, to parametrise them, one required to use and access the variables. It should now be easier to achieve the same result.

For example, to filter only chunks which are greater than X

[
  base:filter (
    "(chunk, _, minValue) => chunk > minValue"^^code:EcmaScript ;
    "X"^^p:VariableName ;
  ) 
] .

Copy link

changeset-bot bot commented Sep 12, 2024

🦋 Changeset detected

Latest commit: 777ce53

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
barnard59-base Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

codecov bot commented Sep 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.77%. Comparing base (ad5f176) to head (777ce53).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #326      +/-   ##
==========================================
+ Coverage   85.30%   85.77%   +0.47%     
==========================================
  Files         177      177              
  Lines        7411     7418       +7     
  Branches      241      241              
==========================================
+ Hits         6322     6363      +41     
+ Misses       1087     1055      -32     
+ Partials        2        0       -2     
Flag Coverage Δ
barnard59 80.02% <ø> (ø)
barnard59-base 49.39% <100.00%> (+0.53%) ⬆️
barnard59-core 92.38% <ø> (+1.40%) ⬆️
barnard59-csvw 69.69% <ø> (+1.21%) ⬆️
barnard59-cube 96.80% <ø> (+1.36%) ⬆️
barnard59-formats 28.17% <ø> (ø)
barnard59-ftp 97.60% <ø> (ø)
barnard59-graph-store 95.10% <ø> (ø)
barnard59-http 89.24% <ø> (+2.15%) ⬆️
barnard59-rdf 94.84% <ø> (ø)
barnard59-s3 100.00% <ø> (ø)
barnard59-shacl 80.21% <ø> (ø)
barnard59-sparql 94.93% <ø> (ø)
barnard59-validation 97.53% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

},
})

const prependPrefix = (chunk, prefix) => prefix + chunk
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the additional variadic argument is not needed using partial application:

const prependPrefix = prefix => chunk => prefix + chunk
const outStream = input.pipe(map.call(context, prependPrefix('foo_')))

But expressing partial application as code snippets b59 turtle files is more cumbersome, so probably the variadic arg solution is the best option

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an intriguing idea but I agree that the turtle representation would likely be more complicated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants