Registry / productivity / ctgov-ocr-formatter

ctgov-ocr-formatter

JSON →
library1.0.2jsnpmunverified

Simple string formatter for cleaning up clinical trial parsed data from CTGOV (ClinicalTrials.gov). Removes unnecessary carriage returns and line breaks to produce display-friendly strings for web and mobile pages. Version 1.0.2, stable. Uses regex and standard string functions. Differentiator: focused solely on formatting CTGOV OCR output.

npm install ctgov-ocr-formatter
INSTALL
IMPORT
SIG · CTGOV-OCR-FORMATTE
C
ctgov-ocr-formatter
productivityjavascriptv1.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Formatter
import { Formatter } from 'ctgov-ocr-formatter'
import Formatter from 'ctgov-ocr-formatter'
Named export, not default.
Formatter
const { Formatter } = require('ctgov-ocr-formatter')
const Formatter = require('ctgov-ocr-formatter')
Destructure named export even in CommonJS.
Formatter
import { Formatter } from 'ctgov-ocr-formatter'
import * as fmt from 'ctgov-ocr-formatter'; new fmt.Formatter()
Direct named import works, no need for namespace.

Shows how to instantiate Formatter and call formatData to clean up a textblock from CTGOV data.

// ESM usage import { Formatter } from 'ctgov-ocr-formatter'; // Assume we have parsed XML data from ClinicalTrials.gov const result = { clinical_study: { eligibility: [{ criteria: [{ textblock: ['Inclusion Criteria:\n- Age 18+\r\n- Willing to consent'] }] }] } }; const formatter = new Formatter(); const rawText = result.clinical_study.eligibility[0].criteria[0].textblock[0]; const formatted = formatter.formatData(rawText); console.log(formatted); // Output: "Inclusion Criteria:\n- Age 18+\n- Willing to consent"
Debug
Known issues
gotchaformatData expects a string; passing a non-string may cause errors.
fix
Ensure argument is a string (e.g., from textblock[0]) before calling formatData.
affects: all
deprecatedThe library has no TypeScript declarations; use at your own risk in TS projects.
fix
Create a declaration file (ctgov-ocr-formatter.d.ts) with: declare module 'ctgov-ocr-formatter' { export class Formatter { formatData(data: string): string; } }
affects: all
gotchaformatData does not preserve intentional line breaks; all ' ' are replaced with newline characters.
fix
Use formatData only for removing extraneous carriage returns; if you need to keep specific formatting, preprocess the string.
affects: all
Errors
Common errors & fixes
TypeError: formatter.formatData is not a function
Importing incorrectly (e.g., default import or wrong destructuring).
fix
Use import { Formatter } from 'ctgov-ocr-formatter' or const { Formatter } = require('ctgov-ocr-formatter').
Cannot find module 'ctgov-ocr-formatter'
Package not installed or typo in import.
fix
Run 'npm install ctgov-ocr-formatter' and verify package.json includes it.
Uncaught TypeError: Cannot read property 'formatData' of undefined
new Formatter() returned undefined?
fix
Ensure you are using new Formatter() (with new) and the import is correct.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
14
OpenAI (training)
1
Resources
ctgov-ocr-formatter — npm install ctgov-ocr-formatter · libregistry