Remove danfojs-node; inline the small CSV piece we used#16
Merged
Conversation
danfojs-node was used only to read a CSV into rows and drop incomplete ones, yet it dragged in @tensorflow/tfjs-node, xlsx, and the deprecated request package — the single largest source of security alerts, several of which have no published npm fix (xlsx moved off npm; request is unmaintained). Following the pattern of #6 (inlining langchain's Document), we inline that tiny piece and drop the dependency. Changes: - Add src/utils/csv.ts: a compact RFC-4180 CSV parser (handles quoted fields, embedded commas/newlines, escaped quotes, CRLF) plus a dropEmptyRows() helper mirroring danfojs' dropNa(). - csvLoader.ts returns CSVRow[] instead of a danfojs DataFrame. - index.ts operates on row arrays (slice) instead of DataFrame head/tail/toJSON/dropNa. - Delete src/utils/dataLoader.ts: dead code (nothing imported it) and the only consumer of json2csv and cross-fetch. - Drop danfojs-node, json2csv, cross-fetch, and @types/json2csv from package.json. - Add tests/csv.test.ts covering the parser's edge cases. Removes danfojs-node, @tensorflow/tfjs-node, xlsx, and request from the dependency tree entirely. npm audit: 46 -> 37 vulnerabilities. Verified: npm run build, tsc --noEmit, npm test (23 pass), npm run lint all green, plus an end-to-end run of splitFile -> loadCSVFile -> dropEmptyRows on a CSV containing quoted commas, an embedded newline, and escaped quotes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause #1 of 3
danfojs-nodewas used only to read a CSV into rows and drop incomplete ones, yet it dragged in@tensorflow/tfjs-node,xlsx, and the deprecatedrequestpackage — the single largest source of security alerts in this repo. Several of those alerts have no published npm fix (xlsxmoved off npm;requestis unmaintained), so they can't be resolved with version overrides — the dependency has to go.Following the pattern of #6 (inlining langchain's
Document), this PR inlines the tiny piece we actually used and drops the dependency.Changes
src/utils/csv.ts— a compact RFC-4180 CSV parser (handles quoted fields, embedded commas/newlines, escaped""quotes, CRLF) plus adropEmptyRows()helper mirroring danfojs'dropNa().csvLoader.tsreturnsCSVRow[]instead of a danfojsDataFrame.index.tsoperates on row arrays (slice) instead ofDataFramehead/tail/toJSON/dropNa.src/utils/dataLoader.ts— dead code (nothing imported it) and the only consumer ofjson2csvandcross-fetch.package.json— dropdanfojs-node,json2csv,cross-fetch,@types/json2csv.tests/csv.test.tscovering the parser's edge cases.Impact
Removes
danfojs-node,@tensorflow/tfjs-node,xlsx, andrequestfrom the dependency tree entirely (including the unfixablexlsx/requestalerts).npm audit: 46 → 37.Verification
npm run build,tsc --noEmit,npm test(23 pass, 9 new),npm run lint— all green.splitFile → loadCSVFile → dropEmptyRowson a CSV containing quoted commas, an embedded newline (split across physical lines byfileSplitter, then reassembled), a missing column, and escaped quotes — all parsed/filtered correctly.Context
First of three root-cause PRs replacing the closed overrides PR (#15). Follow-ups: migrate
@xenova/transformers→@huggingface/transformers(protobufjs/onnxruntime cluster), and upgradevitestv2 → v3 (dev tooling cluster + form-data/lodash via jsdom).🤖 Generated with Claude Code