-
-
Notifications
You must be signed in to change notification settings - Fork 835
feat: add iter/cusome-by
#2661
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: add iter/cusome-by
#2661
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.
👋 Hi there! 👋
And thank you for opening your first pull request! We will review it shortly. 🏃 💨
@kgryte Please review this PR . |
Here's the adapted README.md for `cusome-by`, based on the `some-by` version: | ||
|
||
```markdown |
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.
This is not how to write README files. Furthermore, the README name is incorrect. We don't uppercase MD
.
* * * | ||
|
||
## See Also | ||
|
||
- <span class="package-name">[`@stdlib/iter/cuany-by`][@stdlib/iter/cuany-by]</span><span class="delimiter">: </span><span class="description">create an iterator which iteratively applies a test function to iterated values, returning `true` if a test is passed and `false` otherwise.</span> | ||
- <span class="package-name">[`@stdlib/iter/cuevery-by`][@stdlib/iter/cuevery-by]</span><span class="delimiter">: </span><span class="description">create an iterator which iteratively applies a test function to iterated values, returning `false` if a test fails and `true` otherwise.</span> | ||
- <span class="package-name">[`@stdlib/iter/for-each`][@stdlib/iter/for-each]</span><span class="delimiter">: </span><span class="description">create an iterator which invokes a function for each iterated value before returning the iterated value.</span> | ||
- <span class="package-name">[`@stdlib/iter/cunone-by`][@stdlib/iter/cunone-by]</span><span class="delimiter">: </span><span class="description">create an iterator which iteratively applies a test function to iterated values, returning `true` if all values fail and `false` otherwise.</span> | ||
- <span class="package-name">[`@stdlib/iter/cusome`][@stdlib/iter/cusome]</span><span class="delimiter">: </span><span class="description">create an iterator which iteratively checks whether at least `n` iterated values are truthy.</span> |
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.
Do not manually edit this section. See the comment at L197. This section should be empty.
<!-- <related-links> --> | ||
|
||
[@stdlib/iter/cuany-by]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/cuany-by | ||
|
||
[@stdlib/iter/cuevery-by]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/cuevery-by | ||
|
||
[@stdlib/iter/for-each]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/for-each | ||
|
||
[@stdlib/iter/cunone-by]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/cunone-by | ||
|
||
[@stdlib/iter/cusome]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/iter/cusome | ||
|
||
<!-- </related-links> --> |
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.
These should be removed.
function predicate( v ) { | ||
return ( v > 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.
You did not setup EditorConfig. Please read our contributing guidelines.
@@ -0,0 +1,49 @@ | |||
The predicate function is provided two arguments: |
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.
This file does not adhere to project conventions. See the REPL text guide in /docs
.
/** | ||
* Interface for the returned iterator. | ||
*/ | ||
interface CuSomeByIterator extends Iterator { |
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.
Why are you doing this? Use TypedIterator
from @stdlib/types/iter
. Furthermore, if the source iterator is iterable, the returned iterable should also be iterable. See other @stdlib/iter/*
packages.
@@ -0,0 +1,106 @@ | |||
import iterCuSomeBy = require( './index' ); |
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.
Missing license header. Incorrect indentation throughout the file.
|
||
|
||
|
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.
Why do you have multiple trailing lines?
break; | ||
} | ||
console.log( v.value ); | ||
} |
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.
EditorConfig.
|
||
// EXPORTS // | ||
|
||
module.exports = main; |
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.
EditorConfig.
return { | ||
'value': false, | ||
'done': false | ||
}; |
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.
return { | |
'value': false, | |
'done': false | |
}; | |
return v; |
|
||
// EXPORTS // | ||
|
||
module.exports = iterCuSomeBy; |
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.
EditorConfig.
@@ -0,0 +1,73 @@ | |||
{ | |||
"name": "@stdlib/iter/cusome-by", |
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.
Indentation in this file is off.
"cusome", | ||
"transform" | ||
] | ||
} |
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.
EditorConfig.
tape( 'the function returns an iterator', function test( t ) { | ||
var it = iterCuSomeBy( array2iterator( [ 1, 1, 0, 0, 1 ] ), 3, predicate ); | ||
t.equal( typeof it.next, 'function', 'has next method' ); | ||
// t.equal( typeof it.return, 'function', 'has return method' ); |
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.
Don't leave commented code.
|
||
it = iterCuSomeBy( array2iterator( values ), 2, predicate ); | ||
t.equal( typeof it.next, 'function', 'has next method' ); | ||
// t.equal( typeof it.return, 'function', 'has return method' ); |
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.
Same thing.
t.equal( typeof r.value, 'boolean', 'returns a boolean' ); | ||
t.equal( r.done, false, 'returns expected value' ); | ||
|
||
// r = it.return(); |
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.
Why did you do this? Now the test does not test what it is supposed to.
t.equal( typeof r.value, 'boolean', 'returns a boolean' ); | ||
t.equal( r.done, false, 'returns expected value' ); | ||
|
||
// r = it.return( 'finished' ); |
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.
Same thing.
this.count += 1; // eslint-disable-line no-invalid-this | ||
return ( v > 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.
EditorConfig.
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.
Why did you include this file? Remove.
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.
This PR needs significant changes before it can be considered for further review. Please study existing packages in @stdlib/iter/*
and emulate the style and conventions as closely as possible and as appropriate. And further, please be sure to setup your local dev environment for contributing to stdlib as discussed in the contributing guidelines. It is clear that linting was not setup locally.
@vivek-anand-singh Also, in your OP, you removed the checkbox indicating that you have read the contributing guidelines. Without that checkbox, we cannot accept your PR. Please be sure to include that before any further review. |
Resolves #2338
Description
This pull request:
stdib
Related Issues
This pull request:
@stdlib/iter/cusome-by
#2338@stdlib/iter/cusome-by
#2338Questions
No.
Other
No.