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

Save start, stop, and step as properties of range #59

Open
parzhitsky opened this issue May 13, 2020 · 3 comments
Open

Save start, stop, and step as properties of range #59

parzhitsky opened this issue May 13, 2020 · 3 comments
Labels
Change: minor [Issue / PR] describes a non-breaking change, such as adding a new functionality Domain: main [Issue / PR] describes change in the functionality, its optimization good first issue [Issue] can be addressed by a first-time contributor Pending: blocked [Issue / PR] cannot be addressed until another issue is resolved Priority: medium [Issue / PR] should be addressed without delay Type: improvement [Issue / PR] addresses lack of a functionality or an open possibility of enhancement

Comments

@parzhitsky
Copy link
Member

parzhitsky commented May 13, 2020

In case of numeric implementation, save start, stop, and step as properties of range:

const { start, stop, step } = xrange(10);

start; // 0
stop; // 10
step; // 1
const { start, stop, step } = xrange(2, -3);

start; // 2
stop; // -3
step; // -1
const { start, stop, step } = xrange(42, 17, 5);

start; // 17
stop; // 42
step; // 5
const range = xrange(7, () => true, Math.random);
const { start, stop, step } = range;

start; // undefined
stop; // undefined
step; // undefined

"stop" in range; // true
"step" in range; // true
@parzhitsky parzhitsky added Change: minor [Issue / PR] describes a non-breaking change, such as adding a new functionality Domain: main [Issue / PR] describes change in the functionality, its optimization Priority: medium [Issue / PR] should be addressed without delay Type: improvement [Issue / PR] addresses lack of a functionality or an open possibility of enhancement good first issue [Issue] can be addressed by a first-time contributor labels May 13, 2020
@parzhitsky parzhitsky added the Pending: blocked [Issue / PR] cannot be addressed until another issue is resolved label May 13, 2020
@parzhitsky
Copy link
Member Author

This requires implementing a wrapper around core (@xrange/core) or reimplementing core to plain (although iterator-protocol-compliant) object, rather than a generator.

@parzhitsky
Copy link
Member Author

Blocked by parzh/xrange__core#13

@parzhitsky
Copy link
Member Author

start of a functional iterator is changed to undefined to address #48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Change: minor [Issue / PR] describes a non-breaking change, such as adding a new functionality Domain: main [Issue / PR] describes change in the functionality, its optimization good first issue [Issue] can be addressed by a first-time contributor Pending: blocked [Issue / PR] cannot be addressed until another issue is resolved Priority: medium [Issue / PR] should be addressed without delay Type: improvement [Issue / PR] addresses lack of a functionality or an open possibility of enhancement
Projects
None yet
Development

No branches or pull requests

1 participant