-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Set operations #281
Set operations #281
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. We can add this after the ESM branch has been merged.
src/core/operations/SetOperations.js
Outdated
* | ||
* @author d98762625 [d98762625@gmail.com] | ||
* @copyright Crown Copyright 2018 | ||
* @license APache-2.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo - should be a lowercase 'p'
src/core/operations/SetOperations.js
Outdated
import Utils from "../Utils.js"; | ||
|
||
/** | ||
* Set operations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd probably rename this file to SetOps.js
to fit with the convention (e.g. BitwiseOps.js
)
src/core/config/OperationConfig.js
Outdated
@@ -4018,6 +4019,29 @@ const OperationConfig = { | |||
inputType: "string", | |||
outputType: "number", | |||
args: [] | |||
}, | |||
"Set Operations": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would make more sense to have separate operations for each function (i.e. one op for 'Union', one for 'Intersection', one for 'Set Difference'...). This is what we've done for the arithmetic ops ('Sum', 'Mean' etc.).
src/core/config/Categories.js
Outdated
@@ -331,6 +331,7 @@ const Categories = [ | |||
"Extract EXIF", | |||
"Numberwang", | |||
"XKCD Random Number", | |||
"Set Operations" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add these operations to the 'Arithmetic/Logic' category.
src/core/operations/SetOperations.js
Outdated
* @returns {html} | ||
*/ | ||
runSetOperation(input, args) { | ||
const [sampleDelim, itemDelimiter, operation] = args; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat! I might start using this notation in other ops.
src/core/config/OperationConfig.js
Outdated
module: "Default", | ||
description: "Performs set operations", | ||
inputType: "string", | ||
outputType: "html", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why this is html
? It looks like your output is always just a simple string.
I've edited these operations to the new ESM format. Each operation is now in it's own file. |
@n1474335 Generally do you think we should .gitignore the auto-generated files? It would make these PRs cleaner. |
Yes, that would make sense. |
#236
Set operations are working as described in the example. Item delimiter respected in the output from all operations.
This gives an example of how an operation can be written as a class - it's got minimal difference to the interface with the rest of the app - just the bind in the module config. We can start thinking about declaring the operation class, inheriting from this and including metadata into the class somewhere.
Some things to make sure are OK with this PR:
undefined
. For example,1,2,3 a,b
gives(1,a),(2,b),(3,undefined)
.1-2 a-b
gives(1,a)-(2,b)
Looking forward to any comments you have.