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: add iter/cuevery #2664

Closed
wants to merge 1 commit into from
Closed

Conversation

Dipti0704
Copy link

Resolves #2332.

Description

What is the purpose of this pull request?

This pull request:

  • Implements a new iterator function iterCuevery
  • Adds functionality to cumulatively test whether every iterated value is truthy
  • Enhances the @stdlib/iter module ecosystem

Related Issues

Does this pull request have any related issues?

This pull request:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

  • Input Iterator: The function takes an input iterator.
  • Output Iterator: Returns a new iterator that yields boolean values.
  • Yielding True: Continues yielding true while all values are falsy.
  • Yielding False: Yields false once a truthy value is encountered and for all subsequent iterations.
  • Handling Input: Handles both iterable and non-iterable input iterators.

Checklist

Please ensure the following tasks are completed before submitting this pull request.


@stdlib-js/reviewers

Copy link
Contributor

@stdlib-bot stdlib-bot left a 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. 🏃 💨

@Dipti0704
Copy link
Author

@kgryte can you review this?

Copy link
Member

Choose a reason for hiding this comment

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

This file should not be modified.

Copy link
Member

Choose a reason for hiding this comment

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

This file is empty.

Copy link
Member

Choose a reason for hiding this comment

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

This file does not conform to our REPL text conventions. Please read the REPL text guide.

Copy link
Member

Choose a reason for hiding this comment

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

Missing license header.

* v = it.next().done;
* // returns true
*/
declare function iterCuEvery( iterator: Iterator ): Iterator;
Copy link
Member

Choose a reason for hiding this comment

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

You can improve return value specificity by using the TypedIterator interface.

*/

import iterCuEvery from './index';
//import isIteratorLike from '@stdlib/assert/is-iterator-like';
Copy link
Member

Choose a reason for hiding this comment

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

Why is this here?


// The function returns an iterator...
{
iterCuEvery(iterator()); // $ExpectType Iterator
Copy link
Member

Choose a reason for hiding this comment

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

Incorrect spacing and indentation throughout this file.


// The compiler throws an error if the function is provided a value other than an iterator protocol-compliant object...
{
iterCuEvery(5 as any); // $ExpectError
Copy link
Member

Choose a reason for hiding this comment

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

Why are you casting?

iterCuEvery(undefined as any); // $ExpectError
iterCuEvery([] as any); // $ExpectError
iterCuEvery({} as any); // $ExpectError
//iterCuEvery((x: number): number => x as any as Iterator); // $ExpectError
Copy link
Member

Choose a reason for hiding this comment

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

Why is this commented out?

Comment on lines +57 to +63
// Test iterator with Symbol.iterator if supported
{
const it = iterator();
if (Symbol.iterator in it) {
iterCuEvery(it); // $ExpectType Iterator
}
}
Copy link
Member

Choose a reason for hiding this comment

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

This should be removed.

});

// Create an iterator which applies a threshold to generated numbers:
var it = iterMap( rand, function threshold( r ) {
Copy link
Member

Choose a reason for hiding this comment

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

Do not use function expressions.


// Create an iterator which generates uniformly distributed pseudorandom numbers:
var rand = randu({
'iter': 100
Copy link
Member

Choose a reason for hiding this comment

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

This file has incorrect indentation.

Copy link
Member

Choose a reason for hiding this comment

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

This file is empty.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, this file should be removed.

Comment on lines +24 to +28
* @module @stdlib/iter-cuevery
*
* @example
* var array2iterator = require( '@stdlib/array-to-iterator' );
* var iterCuEvery = require( '@stdlib/iter-cuevery' );
Copy link
Member

Choose a reason for hiding this comment

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

Incorrect module names. See other packages within the monorepo.

Comment on lines +63 to +64


Copy link
Member

Choose a reason for hiding this comment

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

Why are these spaces here?

Comment on lines +66 to +68
if (!isIteratorLike(iterator)) {
throw new TypeError(format('invalid argument. Must provide an iterator. Value: `%s`.', iterator));
}
Copy link
Member

Choose a reason for hiding this comment

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

Incorrect spacing and indentation. It is clear that you failed to setup your local development environment, as our linting would have caught these errors. Please read our contributing guidelines.

}
if (!v.value) {
FLG = false;
done = true; // Short-circuit once a falsy value is found
Copy link
Member

Choose a reason for hiding this comment

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

This is not correct behavior. This is a cumulative iterator and should have the same length as the source iterator.


return iter;

function next() {
Copy link
Member

Choose a reason for hiding this comment

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

You're missing JSDoc comments.

Comment on lines +70 to +73
var FLG = true; // Assume all values are truthy initially
var done = false;

var iter = {
Copy link
Member

Choose a reason for hiding this comment

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

This isn't how we do variable declarations in source files.

};
}

function finish(value) {
Copy link
Member

Choose a reason for hiding this comment

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

JSDoc comments.

};
}

function factory() {
Copy link
Member

Choose a reason for hiding this comment

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

JSDoc comments.


// EXPORTS //

module.exports = iterCuEvery;
Copy link
Member

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 per the contributing guidelines.

Copy link
Member

Choose a reason for hiding this comment

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

Why is this file here? Remove.

"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
}
],
"license": "ISC",
Copy link
Member

Choose a reason for hiding this comment

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

What is this? This package.json is not how we do things. See other packages.

Comment on lines +1 to +21
// /**
// * @license Apache-2.0
// *
// * Copyright (c) 2024 The Stdlib Authors.
// *
// * Licensed under the Apache License, Version 2.0 (the "License");
// * you may not use this file except in compliance with the License.
// * You may obtain a copy of the License at
// *
// * http://www.apache.org/licenses/LICENSE-2.0
// *
// * Unless required by applicable law or agreed to in writing, software
// * distributed under the License is distributed on an "AS IS" BASIS,
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// * See the License for the specific language governing permissions and
// * limitations under the License.
// */




Copy link
Member

Choose a reason for hiding this comment

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

Why are you commenting out our license header?

Copy link
Member

Choose a reason for hiding this comment

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

This file does not follow project conventions.

Copy link
Member

Choose a reason for hiding this comment

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

Why did you delete this file?

Copy link
Member

@kgryte kgryte left a 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 modifications before it can be reviewed again and considered for inclusion in the project.

@kgryte kgryte changed the title feat(iter): add cuevery function feat: add iter/cuevery Jul 28, 2024
@kgryte kgryte added Feature Issue or pull request for adding a new feature. Needs Changes Pull request which needs changes before being merged. labels Jul 28, 2024
@Planeshifter Planeshifter added the autoclose: Stale Pull request which should be auto-closed as considered stale. label Oct 13, 2024
@stdlib-bot
Copy link
Contributor

This pull request has been automatically closed because it has been inactive for an extended period after changes were requested. If you still wish to pursue this contribution, feel free to reopen the pull request or submit a new one.

We appreciate your interest in contributing to stdlib!

@stdlib-bot stdlib-bot closed this Oct 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autoclose: Stale Pull request which should be auto-closed as considered stale. Feature Issue or pull request for adding a new feature. Needs Changes Pull request which needs changes before being merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC]: add @stdlib/iter/cuevery
4 participants