Description
The formatJSON function is currently internal-only. It should be exported from the public API to allow programmatic use.
Current State
// packages/device-profiler/src/index.ts
// formatJSON is NOT exported
Users wanting to format scan results as JSON programmatically must either:
- Use the CLI tool only
- Import directly from internal path (fragile)
Proposed Change
Add to packages/device-profiler/src/index.ts:
export { formatJSON, type JSONFormatterOptions } from './json-formatter.js'
Use Case
Libraries or tools that use scanRegisters() directly may want to format results as JSON:
import { scanRegisters, formatJSON } from '@ya-modbus/device-profiler'
const results = []
await scanRegisters({
// ... options
onResult: (r) => results.push(r)
})
const json = formatJSON(results, {
type: RegisterType.Holding,
startAddress: 0,
endAddress: 100,
batchSize: 10,
port: '/dev/ttyUSB0'
})
Impact
- No breaking changes (pure addition)
- Enables programmatic JSON formatting
- Consistent with other exported formatters (formatProgress, formatSummary)
Related
Identified in aspected review of #<PR_NUMBER>
Description
The
formatJSONfunction is currently internal-only. It should be exported from the public API to allow programmatic use.Current State
Users wanting to format scan results as JSON programmatically must either:
Proposed Change
Add to
packages/device-profiler/src/index.ts:Use Case
Libraries or tools that use
scanRegisters()directly may want to format results as JSON:Impact
Related
Identified in aspected review of #<PR_NUMBER>