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: Introduce SampledProperty new function getSample #12253

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

s3xysteak
Copy link
Contributor

@s3xysteak s3xysteak commented Oct 15, 2024

Description

The PR add a new function getSample to SampledProperty, which provides a feature to get the time of samples by index.

Issue number and link

Closes #12245.

Testing plan

Technically speaking, it only performs simple operations on arrays. I add a simple unit test to check if it works well.

Author checklist

  • I have submitted a Contributor License Agreement
  • I have added my name to CONTRIBUTORS.md
  • I have updated CHANGES.md with a short summary of my change
  • I have added or updated unit tests to ensure consistent code coverage
  • I have updated the inline documentation, and included code examples where relevant
  • I have performed a self-review of my code

Copy link

Thank you for the pull request, @s3xysteak!

✅ We can confirm we have a CLA on file for you.

@ggetz
Copy link
Contributor

ggetz commented Oct 15, 2024

Thanks for the PR @s3xysteak!

@lukemckinstry Could you please review?

Copy link
Contributor

@lukemckinstry lukemckinstry left a comment

Choose a reason for hiding this comment

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

Thanks @s3xysteak for this PR!
Looks good 👍 One minor question.
@ggetz you may want to take a quick look as well.

*/
SampledProperty.prototype.getSample = function (index) {
//>>includeStart('debug', pragmas.debug);
Check.defined("index", index);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think it would be good to check that the index is within range? Or is it better to allow an out of range index and return undefined?

if (index < -this._times.length || index >= this._times.length) {
throw new DeveloperError("Index out of bounds.");
}

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

Successfully merging this pull request may close these issues.

Request SampledProperty exposes its _times
3 participants