Skip to content

Conversation

@zwerg4
Copy link

@zwerg4 zwerg4 commented Sep 24, 2025

Summary

This commit should add the feature requested in #12.
When parsing the values in 'handleIncomingLine' it replaces starting and ending parens.

Motivation & Context

Closes #12

Changes

  • handleIncomingLine added parens handling

How to Test

@todbot

  1. run and test with new data

Checklist

  • I ran npm run lint and fixed any issues
  • I ran npm run typecheck (TypeScript) with no errors
  • I ran npm test and tests pass
  • I ran npm run test:coverage if code paths changed significantly
  • I added/updated tests where appropriate
  • I updated docs/README if needed
  • No breaking changes without clear migration notes

Additional Notes

@todbot
Copy link

todbot commented Sep 26, 2025

Thanks! I've verified this works great for Python tuples ((1,2,3)) and that addresses my initial issue.
Some folk might want it to also support Python lists ([1,2,3]), just FYI.

btw, some Micropython/CircuitPython code you can use to quickly try this out is:

import time, math
while True:
    t = time.monotonic() % 2*math.pi   
    vals = t, math.sin(t), math.cos(t)
    print(vals)              # prints python tuple () 
    #print(list(vals))    # prints python list []
    time.sleep(0.05)

@cgreening cgreening requested review from cgreening and Copilot October 1, 2025 21:33
@cgreening cgreening merged commit be5ba51 into atomic14:main Oct 1, 2025
3 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds support for handling parentheses in datastream values by stripping leading and trailing parentheses from both series names and data values during parsing.

  • Modifies the handleIncomingLine function to remove leading ( and trailing ) characters
  • Updates both series name parsing (lines starting with #) and data value parsing

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

// Parse for chart (existing logic)
if (line.trim().startsWith('#')) {
const names = line.replace(/^\s*#+\s*/, '').split(/[\s,\t]+/).filter(Boolean)
const names = line.replace(/^\(/, '').replace(/\)$/, '').replace(/^\s*#+\s*/, '').split(/[\s,\t]+/).filter(Boolean)
Copy link

Copilot AI Oct 1, 2025

Choose a reason for hiding this comment

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

The parentheses removal logic should be applied after the hash symbol removal, not before. The current order may incorrectly handle cases where parentheses are part of the hash prefix (e.g., '#(data)'). Consider reordering: line.replace(/^\s*#+\s*/, '').replace(/^\(/, '').replace(/\)$/, '')

Suggested change
const names = line.replace(/^\(/, '').replace(/\)$/, '').replace(/^\s*#+\s*/, '').split(/[\s,\t]+/).filter(Boolean)
const names = line.replace(/^\s*#+\s*/, '').replace(/^\(/, '').replace(/\)$/, '').split(/[\s,\t]+/).filter(Boolean)

Copilot uses AI. Check for mistakes.
// Parse for chart (existing logic)
if (line.trim().startsWith('#')) {
const names = line.replace(/^\s*#+\s*/, '').split(/[\s,\t]+/).filter(Boolean)
const names = line.replace(/^\(/, '').replace(/\)$/, '').replace(/^\s*#+\s*/, '').split(/[\s,\t]+/).filter(Boolean)
Copy link

Copilot AI Oct 1, 2025

Choose a reason for hiding this comment

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

The parentheses removal logic is duplicated. Consider extracting this into a helper function to improve maintainability and ensure consistent behavior across both parsing paths.

Copilot uses AI. Check for mistakes.
return
}
const parts = line.trim().split(/[\s,\t]+/).filter(Boolean)
const parts = line.trim().replace(/^\(/, '').replace(/\)$/, '').split(/[\s,\t]+/).filter(Boolean)
Copy link

Copilot AI Oct 1, 2025

Choose a reason for hiding this comment

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

The parentheses removal logic is duplicated. Consider extracting this into a helper function to improve maintainability and ensure consistent behavior across both parsing paths.

Copilot uses AI. Check for mistakes.
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.

[Feature]: Support comma-separated values

4 participants